Jump to content

Recommended Posts

Posted (edited)

Alright as title says. Let's say we got an xml and we want to store objects which is a range of type. 

int[], ArrayLists, Strings e.t.c

 

Known ways:

 

1. Create ex. FastMap into FastMaps such as  FastMap<Integer, FastMap<String, int[]>>

which is complicated to put and retrieve objects.

 

2. Stats sets that contain other stats sets. We can add one statset into another and make a tree

 

Is there any other way and more efficient in order load items from xmls and  store them?

 

Ps. i would prefer an experienced person with java structure to answer and give other solutions that really make it easier and more dynamic.

Thanks

Edited by AccessDenied
Posted (edited)

A StatSet is nothing more than a extended HashMap with more methods, allowing you for a String key to retrieve any type of object. It allows easy fill on loading, for the cost of overhead. A StatSet shouldn't really be used because of the overhead generated by String key. You could for example move every single variable from L2PcInstance into a single StatsSet (which will allow you to drop every single getter and setter). Will you do it, knowing that you must .get( the Map when you could simply retrieve the correct boolean/int/String by yourself with a getter if that was written normally ? I don't think so.

 

Also, a FastMap got no use at all to load static data, you both don't need the potential concurrency from .shared(true), nor the ordered system. You just create overhead for nothing using a FastMap.

 

The proper way is to create you own class defining the object similar to... Everything else :P. For example, Castle is an object, filled by database on startup. On aCis I recently moved hardcoded or SQL data related to static stuff to XML, but basically the Castle object is filled with int, List<MercenaryTicket>, List<Integer>, etc etc...

 

So long answer short, create your own Object class holding properties, then either use a StatsSet to feed that object or put every single parameters in the constructor :

public class Castle
{
     int _castleId;
     String _name;

     // By feeding each parameters into constructor
     public Castle(int id, String name)
     {
          _castleId = id;
          _name = name;
     }


     // By feeding using a StatsSet
     public Castle(StatsSet data)
     {
          _castleId = data.getInteger("castleId");
          _name = data.getString("name");
     }
}

Obviously StatsSet is just more readable when you got 10, 15, 20 parameters to pass on the godamn constructor.

 

You can also feed your object using public setter. As you can see, the castle exemple simply got 2 properties when it normally got billions other (artifact id, circlet, list of mercenary tickets,...). The XML handles that scenario when parsing the XML :

...
if ("artifact".equalsIgnoreCase(cat.getNodeName()))
	castle.setArtifacts(cat.getAttributes().getNamedItem("val").getNodeValue());
...

And then, on Castle object :

public void setArtifacts(String idsToSplit)
{
	for (String idToSplit : idsToSplit.split(";"))
		_artifacts.add(Integer.parseInt(idToSplit));
}

That scenario is right for anything :

- ArmorSetTable uses ArmorSet as storage object.

- FishTable uses FishData

- CastleManager uses Castle

etc etc.

 

On aCis and latest L2J, you also have generic holders such as IntIntHolder which avoid to generate your own class but simply retrieve it from a id/value. IntIntHolder is useful to store skillId, skillLevel or itemId, price. Beware, IntIntHolder is still an object to create - it simply avoids you to write your own little inner classes when you need only to store a paired int/int.

Edited by Tryskell
Posted

A StatSet is nothing more than a extended HashMap with more methods, allowing you for a String key to retrieve any type of object. It allows easy fill on loading, for the cost of overhead. A StatSet shouldn't really be used because of the overhead generated by String key. You could for example move every single variable from L2PcInstance into a single StatsSet (which will allow you to drop every single getter and setter). Will you do it, knowing that you must .get( the Map when you could simply retrieve the correct boolean/int/String by yourself with a getter if that was written normally ? I don't think so.

 

Also, a FastMap got no use at all to load static data, you both don't need the potential concurrency from .shared(true), nor the ordered system. You just create overhead for nothing using a FastMap.

 

The proper way is to create you own class defining the object similar to... Everything else :P. For example, Castle is an object, filled by database on startup. On aCis I recently moved hardcoded or SQL data related to static stuff to XML, but basically the Castle object is filled with int, List<MercenaryTicket>, List<Integer>, etc etc...

 

So long answer short, create your own Object class holding properties, then either use a StatsSet to feed that object or put every single parameters in the constructor :

public class Castle
{
     int _castleId;
     String _name;

     // By feeding each parameters into constructor
     public Castle(int id, String name)
     {
          _castleId = id;
          _name = name;
     }


     // By feeding using a StatsSet
     public Castle(StatsSet data)
     {
          _castleId = data.getInteger("castleId");
          _name = data.getString("name");
     }
}

Obviously StatsSet is just more readable when you got 10, 15, 20 parameters to pass on the godamn constructor.

 

You can also feed your object using public setter. As you can see, the castle exemple simply got 2 properties when it normally got billions other (artifact id, circlet, list of mercenary tickets,...). The XML handles that scenario when parsing the XML :

...
if ("artifact".equalsIgnoreCase(cat.getNodeName()))
	castle.setArtifacts(cat.getAttributes().getNamedItem("val").getNodeValue());
...

And then, on Castle object :

public void setArtifacts(String idsToSplit)
{
	for (String idToSplit : idsToSplit.split(";"))
		_artifacts.add(Integer.parseInt(idToSplit));
}

That scenario is right for anything :

- ArmorSetTable uses ArmorSet as storage object.

- FishTable uses FishData

- CastleManager uses Castle

etc etc.

 

On aCis and latest L2J, you also have generic holders such as IntIntHolder which avoid to generate your own class but simply retrieve it from a id/value. IntIntHolder is useful to store skillId, skillLevel or itemId, price. Beware, IntIntHolder is still an object to create - it simply avoids you to write your own little inner classes when you need only to store a paired int/int.

 

 

First of all thanks for being serious. Afcourse Sset is more readable by user when you play with 10 different objects and variables example to store an Event Data which require let's say

1. team color (FastMap)

2. team name (FastMap)

3. map data which contain team position (FastMap into FastMap)

 

e.t.c and i don't know how many more variables can you store but since i made an event and i'm using FastMaps to store objects after 4 fastMaps it kinda start getting ridiculously hard. I mean only the idea

get(x).get(x).get(x).get(x) after 5 times it kill my brain.

 

Also i'm not really familiar when it come in Statset to load from xml. Everytime you load data from xml you have plenty of options and if they exist since you're using

 

 

 

if ("artifact".equalsIgnoreCase(cat.getNodeName()))

 

so since we don't know how many variables are loaded we can't set the statset. Maybe is complicated in my head thats why i asked any alternative idea. I want avoid making different classes

to make objects, i want keep all in 1 class and all in 1 method and make a simple style like    xxxx.getEvent(1).getData().getEventMap(1).getPositionForTeam(1); or something simple like that to avoid the 

mess i have right now with different classes. The idea behind this is to make a statsset that as you said extends HMs and contain other elements or other statsets inside if i'm right. The idea is pretty much easy.

I don't really want an example or anything i just wanted to know if the way i mention is better to be done with Sset or any other way in order to avoid making different classes and keep all in 1. 

 

Thanks again.

Posted

Are you trolling again or what? :lol:

No i'm actualy asking advice of someone more experienced to tell me if is ok to continue the idea i mentionted with the Sset or what. 

No searching for solution or examples just a yes or no and if is fine.

Posted

I answered you, StatsSet generates a overhead where basic properties don't. StatsSet should be kept only for data feeding.

 

And you obviously know what data you are loading for a raw stuff like Event. If you got a followup of get.get.get, it simply shows how terrible you structured your stuff. That's the sort of stuff to think BEFORE coding it.

 

An Event class probably has :

- int _id

- String _description

- List<L2PcInstance> _players

- List<Location> (or SpawnLocation) _spawnPoints

 

A Team class (can be edited for an extended enum) is different than a Event class. Don't melt everything. It probably has :

- int _id

- String _name

- int _color

 

etc etc.

Posted

It really depends what you want to do.

What should be taken into consideration:

- If object will change in time or loaded just once

- If it will be changed from multiple threads at the time

- How long(size, length) is it going to be

- What kind of access to it you want to have. It will be just fully iterated often, get(x), maybe you just want to take first index and then remove it?

 

Don't use FastList just because it is "fast".

 

If you want to load data from xml, i strongly suggest simple array(or obviously arrayList which might be later .trimToSize()).

 

Don't make FastMap<Integer, FastMap<String, int[]>>

Make:

ArrayList<MyContainer>();

class MyContainer
{
    private final int id;
    private final List<MySecondContainer> importantNameHere;
}

class MySecondContainer
{
    private final int String nameMaybe;
    private final int[] someKindOfData;
}

Thats most secure way.

- How long(size, length) is it going to be

Posted (edited)

It really depends what you want to do.

What should be taken into consideration:

- If object will change in time or loaded just once

- If it will be changed from multiple threads at the time

- How long(size, length) is it going to be

- What kind of access to it you want to have. It will be just fully iterated often, get(x), maybe you just want to take first index and then remove it?

 

Don't use FastList just because it is "fast".

 

If you want to load data from xml, i strongly suggest simple array(or obviously arrayList which might be later .trimToSize()).

 

Don't make FastMap<Integer, FastMap<String, int[]>>

Make:

ArrayList<MyContainer>();

class MyContainer
{
    private final int id;
    private final List<MySecondContainer> importantNameHere;
}

class MySecondContainer
{
    private final int String nameMaybe;
    private final int[] someKindOfData;
}

Thats most secure way.

- How long(size, length) is it going to be

 

Yeap kinda trying to make it like this

private final FastMap<Integer, ArrayList> _mapLocation = new FastMap<Integer, ArrayList>().shared();
	
	private class MapData
	{
		private String _mapName;
		private FastMap<Integer, ArrayList> mapLocation;
		
		private MapData(String mapName, FastMap<Integer, ArrayList> list)
		{
			_mapName = mapName;
			mapLocation = list;
		}
		
		public ArrayList getMapLocationByOwner(String owner)
		{
			ArrayList list = _mapLocation.get(owner);
			return list;
		}
		
		public String getMapName()
		{
			return _mapName;
		}
	}
	
	/**
	 * 
	 * @param id
	 * @return Selected map base on input id
	 */
	public MapData getMapById(int id)
	{
		if (_mapData.containsKey(id))
			return _mapData.get(id);
		else
			System.out.print("Error trying get null MAP");
		
		return null;
	}

Thats why i did until now but still is a bit fucked up..

 

And in ArrayList imma put HashMaps tho. Ps ignore the "_mapLocation.get(owner);"

Edited by AccessDenied
Posted

First of all, those locations are going to be just loaded and stay the same until server or xml restart yes? Then you dont need to make them .shared().

If you dont need shared, why bother to use FastMap at all, it is better to use HashMap.

 

Since you are querying the data by just .get(ID), map will be faster than list or set or other collections. 

You should notice that Map<Integer, something> creates Integer object for each record. Integer is not the same as int, it takes far more memory. If you have small collection, thats fine, why would we care. If you have big collection like all items, thats big deal.

Also in getMapById(int) int is cast to Integer, it takes additional time, but thats fine. You might use .getOrDefault in there, takes just 1 line.

 

ArrayList thing in MapData i skip.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



  • Posts

    • @Celestine  sorry for mu question , and post it's to old but i want to ask  ?   do you have uncrypted interface x dat of this interface? i want to add custom autofarm button but when i open it with xdat say file seems  to be  encrypted. thanks!
    • General Trackers :   IPTorrents invite IPTorrents account 1 tb TorrentLeech invite Torrentleech account 1 tb buffer  InTheShaDow ( ITS ) account Acid-lounge invite Torrentday invite Crnaberza account Abn.Lol account Limit-of-eden account Norbits account Xspeeds account Xspeeds invite Bemaniso invite Wigornot account Bithumen invite Filelist account Funfile invite AvistaZ invite Potuk.net invite ResurrectThe.Net invite GrabThe.Info invite Greek-Team invite LinkoManija invite Fano.in account tracker.czech-server.com Speed.cd invite Arab-torrents.net account Arabscene.me account Scenetime account 4thd.xyz invite Btarg.com.ar account Dedbit invite Estone.cc account Speedapp invite Finvip invite Fluxzone account GigaTorrents account Gimmepeers account Haidan.video invite Mojblink account Mycarpathians invite Newinsane.info account Oscarworld.xyz account Peers.FM invite Pt.msg.vg account Ransackedcrew account Redemption invite Scene-rush account Seedfile.io invite Teracod invite Torrent.ai account Torrentmasters invite Ttsweb invite X-files invite X-ite invite Ncore account TorrentHR account Rptorrents account BwTorrents account Superbits invite Krazyzone account Immortalseed account Tntracker invite Pt.eastgame.org account Bitturk account Rstorrent account Tracker.btnext invite Torrent-turk.de account BeiTai.PT account Pt.keepfrds account 52pt.site account Pthome account Torrentseeds account Aystorrent account Blues-brothers.biz invite Divteam account Thesceneplace invite CinemaMovies.pl account Brasiltracker account Patiodebutacas account Newheaven.nl account  Swarmazon.club invite Bc-reloaded account Crazyspirits account Silentground invite Omg.wtftrackr invite Milkie.cc invite Breathetheword invite Madsrevolution account Chilebt account Yubraca account Uniongang.tv account Frboard account Exvagos account Diablotorrent account Microbit account Carp-hunter.hu account Majomparade.eu account Theshinning.me account Youiv.info account Dragonworld-reloaded account Sharewood.tv account Partis.si account Digitalcore.club invite Fuzer.me account R3vuk.wtf invite Ztracker account 1 tb buffer 3changtrai account Best-core.info account Bitsite.us account Eliteunitedcrew invite Exitorrent.org account Tophos invite Torrent.lt account Sktorrent.eu account Oshen account Blackhattorrent account Pirata.digital account Esharenet account Ohmenarikgi.la Pirate-share account Immortuos account Kiesbits account Cliente.amigos-share.club account Broadcity invite Ilovetorzz account Torrentbytes account Polishsource account Portugas invite Shareisland account ArabaFenice account Hudbt.hust.edu.cn account Audiences account Nanyangpt account Pt.sjtu.edu.cn account Pt.zhixing.bjtu.edu.cn account Byr.pt invite Ptfiles invite Red-bits account Pt.hdpost.top account Irrenhaus.dyndns.dk (NewPropaganda) account Mnvv2.info (MaxNewVision V2) account 1ptba.com account Spidertk.top account Film-paleis account Generation-free account Aftershock-tracker account Twilightsdreams account Back-ups.me invite Sor-next.tk ( Spirit Of Revolution ) account Tfa.tf ( The Falling Angels ) account Hdmayi account S-f-p.dyndns.dk ( Share Friends Projekt ) account Unlimitz.biz account Pttime account St-tracker.eu account New-retro.eu account Zbbit account Tigers-dl.net account Jptvts.us account Lat-team account Club.hares.top account Falkonvision-team account Concen account Drugari account T.ceskeforum account Peeratiko.org account Zamunda.se account Central-torrent.eu account h-o-d.org account Torrentleech.pl account Demonoid invite Lst.gg account Fakedoor.store account LaidBackManor account Vrbsharezone.co.uk invite Torrenteros account Arenaelite account Datascene account Tracker.0day.community Tapochek.net invite Ptchina invite Lesaloon account Exyusubs account Therebels.tv account Ubits.club invite Zmpt.cc account Turktorrent.us account Dasunerwarte account Hawke.uno account Monikadesign account Fearnopeer account Alpharatio account Wukongwendao.top account Chinapyg account Azusa.wiki account Yggtorrent.top account Torrentdd account Cyanbug.net invite Hhanclub.top account Wintersakura.net account Xthor account Tctg.pm account Finelite invite Agsvpt.com account Pt.0ff.cc invite Qingwapt.com account Xingtan.one account Ptcafe.club invite W-o-t.pro account Coastal-crew.bounceme.net account Darkpeers.org account Pianyuan.org account Seedpool.org  account Tempelbox account Pt.itzmx.com account Capybarabr.com account Itatorrents.xyz  account Letseed.org account The-new-fun.com  account Malayabits.cc account Trellas.me account Yu-scene.net account Futuretorrent.org account Bitpt.cn account Tocashare.biz  account Videoteka.org  account White-angel.hu account Xbytesv2.li account   Movies Trackers :   Anthelion account Pixelhd account Cinemageddon account DVDSeed account Cinemageddon account Cinemaz account Retroflix account Classix-unlimited - invite Movie-Torrentz (m2g.link) invite Punck-tracker.net account Tmghub account Tb-asian account Cathode-ray.tube account Greatposterwall account Telly account Arabicsource.net account Upload.cx account Crabpt.vip invite Onlyencodes.cc account Exyusubs account Hellashut.net invite Nordichd.sytes.net invite Locadora.cc account   HD Trackers :   Blutopia buffered account Hd-olimpo buffered account Hdf.world account Torrentland.li account HdSky account Hdchina account Chdbits account Totheglory account Hdroute account Hdhome account TorrentCCF aka et8.org account 3DTorrents invite HD-Torrents account Bit-HDTV account HDME.eu invite Hdarea.co account Asiancinema.me account JoyHD invite HDSpace invite CrazyHD invite Bluebird-hd invite Htpt.cc account Hdtime invite Ourbits.club account Hd4fans account Siambit account Privatehd account Springsunday account Tjupt account Hdcity.leniter invite Ccfbits account Discfan account Pt.btschool.club account Ptsbao.club invite Hdzone.me invite Danishbytes account Zonaq.pw account Tracker.tekno3d account Arabp2p account Hd-united account Reelflix.xyz account Hdatmos.club account Anasch.cc invite Tigris-t account Nethd.org account Hd.ai invite Hitpt.com account Hdmonkey account Dragonhd.xyz account Hdclub.eu account Forum.bluraycd.com account Carpt account Hdfun.me invite Pt.hdupt invite Puntotorrent account Ultrahd account Rousi.zip account Bearbit account Hdturk.club account Asiandvdclub account Star-space.net account Nordicq.org account Hdkyl.in account Utp.to account Hdzero account   Music Trackers :   Dicmusic account Music-Vid account Open.cd account LzTr account ProAudioTorrents invite Jpopsuki invite TranceTraffic invite Audionews invite Kraytracker invite Libble.me invite Losslessclub invite Indietorrents.com invite Dimeadozen account Funkytorrents invite Karaokedl account zombtracker.the-zomb account Concertos account Sugoimusic account Satclubbing.club invite Metal.iplay invite Psyreactor invite Panda.cd account Adamsfile account Freehardmusic account Tracker.hqmusic.vn accouunt Twilightzoom account 3 tb buffer Hiresmusic account Metalguru account Musictorrents.org account Musebootlegs.com invite Zappateers.com account Jungleland.dnsalias.com account Naftamusic account   E-Learning Trackers :   Thevault account BitSpyder invite Brsociety account Learnbits invite Myanonamouse account Libranet account 420Project account Learnflakes account Pt.soulvoice.club account P2pelite account Aaaaarg.fail invite Ebooks-shares.org account Abtorrents account Pt.tu88.men invite Docspedia.world invite   TV-Trackers :   Skipthecommericals Cryptichaven account TV-Vault invite Shazbat.TV account Myspleen account Tasmanit.es invite Tvstore.me account Tvchaosuk account Jptv.club account Tvroad.info   XXX - Porn Trackers :   FemdomCult account Pornbay account Pussytorrents account Adult-cinema-network account Bootytape account 1 Tb buffer Exoticaz account Bitporn account Kufirc account Gaytorrent.ru invite Nicept account Gay-torrents.org invite Ourgtn account Pt.hdbd.us account BitSexy account Happyfappy.org account Kamept.com account Lesbians4u.org account   Gaming Trackers :   Mteam.fr account BitGamer invite Retrowithin invite Gamegamept account   Cartoon/Anime/Comic Trackers :   Animeworld account Oldtoons.world account U2.dmhy account CartoonChaos invite Animetorrents account Mononoke account Totallykids.tv account Bakabt.me invite Revanime account Ansktracker account Tracker.shakaw.com.br invite Bt.mdan.org account Skyey2.com account Animetracker.cc Adbt.it.cx invite Tracker.uniotaku.com account Mousebits.com account   Sports Trackers :   MMA-Tracker invite T3nnis.tv invite AcrossTheTasman account RacingForMe invite Sportscult invite Ultimatewrestlingtorrents account Worldboxingvideoarchive invite CyclingTorrents account Xtremewrestlingtorrents account Tc-boxing invite Mma-torrents account Aussierul invite Xwt-classics account Racing4everyone account Talk.tenyardtracker account Stalker.societyglitch invite Extremebits invite Rgfootball.net account F1carreras.xyz account   Software/Apps Trackers :   Brokenstones account Appzuniverse invite Teamos.xyz account Macbb.org account   Graphics Trackers: Forum.Cgpersia account Gfxpeers account Forum.gfxdomain account   Documentary Trackers:   Forums.mvgroup account   Others   Fora.snahp.eu account Board4all.biz account Filewarez.tv account Makingoff.org/forum account Xrel.to account Undergunz.su account Corebay account Endoftheinter.net ( EOTI ) account Thismight.be invite Skull.facefromouter.space account Avxhm.se (AvaxHome) account Ssdforum account Notfake.vip account Intotheinter.net account Tildes.net invite Thetoonz account Usinavirtual account Hdclasico invite HispaShare account Valentine.wtf account Adit-hd account Forum-andr.net account Warezforums account Justanothermusic.site account Forbiddenlibrary.moe account Senturion.to account Movieparadise account Militaryzone account Dcdnet.ru account Sftdevils.net account Heavy-r.com account New-team.org account Ddl.tv account Filewarez.club account Hispamula.org account Hubwarez.tv account Ultim-zone.in account   NZB :   Ninjacentral.co.za account Tabula-rasa.pw account Drunkenslug account Drunkenslug invite Usenet-4all account Brothers-of-Usenet account Dognzb.cr invite Kleverig account Nzb.cat account Nzbplanet.net invite Ng4you.com account Nzbsa.co.za account Bd25.eu account NZB.to account Samuraiplace account Abhdtv.net account Abook.link account Comix.pw account House-of-usenet Secretbinaries.net account Vnext.to account Stockboxx.top account Sky-of-use.net account Prices start from 3 $ to 100 $   Payment methods: Crypto, Neteller, Webmoney, Revolut   If you want to buy something send me a pm or contact me on:   Email: morrison2102@gmail.com   Discord: LFC4LIFE#4173   Telegram: https://t.me/LFC4LIFE4173   Skype: morrison2102@hotmail.com  
    • Pero necesito ser premium :v
  • Topics

×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..