Jump to content

[Best Way To Store Temporary Objects On Ram]


Recommended Posts

Maybe just give a break with maps for some time :)

ah? Bitch i ain't stop :P i never stop, beside i made the code. No tested yet but by  looking at it it looks even if still a trashcode. 

Also agree with rootware statset is for complex systems but ahh. still it's 3 properties with subproperties and subproperties. e.t.c

Edited by AccessDenied
Link to comment
Share on other sites

I mean HashMap, FastMap. Make lists or Sets :)

Same for StatsSet. Make normal class.

Edited by vampir
Link to comment
Share on other sites

I mean HashMap, FastMap. Make lists or Sets :)

Same for StatsSet. Make normal class.

Oh lel my mistake :P sorry as i mentionted ignore HM and FM are temporary i know they suck. 

 

one of the "cons" Map has is that it replace the value if it exist which sometimes we don't really want.. 

 

Ps. thanks for respond and suggestions

Edited by AccessDenied
Link to comment
Share on other sites

In that case you should make an exception:

if(list.contains(x))

    throw new MyException(x.toString());

else

    list.add(x);

 

The thing is, using list in your case would force more object oriented programming.

Link to comment
Share on other sites

In that case you should make an exception:

if(list.contains(x))

    throw new MyException(x.toString());

else

    list.add(x);

 

The thing is, using list in your case would force more object oriented programming.

 

Yap i know imma go try it now.

Ps. i don't think your code would work when you load from *.xml  list.add(x); 

 

and since you can make a method that generate events from 1 to 10 you can't really get a null 

 

int rndEvent = Rnd.get(1,10);

 

getMapById(rndEvent). bla bla

 

so null is not option

Edited by AccessDenied
Link to comment
Share on other sites

In xml parser you should create object that will be then put in list(in holder class).

 

So then you have got a holder containing all possible maps.

 

If you want to choose map for the event:

 

EventMap map = Rnd.get(HolderName.getInstance().getAllMaps());

or

EventMap map = HolderName.getInstance().getRandomMap();

 

You might not have Rnd.get in your pack. it returns any object in range of the collection. Throws exception in case it is empty. It doesnt return null.

Link to comment
Share on other sites

Ah, so you are talking about List<Integer>. I am talking about class X{ int y;}

Btw, why didnt you add Trove but made IntIntHolder on your own?

 

I don't like external libraries. Notably when you use only 2 classes over a whole library. You have to refer on the library javadoc to understand what it does, or what you can do. So I prefer to rely on personal implementations, stored on "commons" package (the only thing russians do fine). Plus IntIntHolder doesn't replace TInt stuff. It just provides most used exotic storage (used 10+ times).

 

Plus, it's a matter of 10mo RAM save for the integrality of List<Integer> and Map<Integer, Integer>. Not worth the point to remember to use Trove.

 

---

 

Access, define your XML structure first, it will normally give you hints about how to load stuff, what variables you need, etc. Create each class accordingly. What's supposed to be owner on MapData ?

Edited by Tryskell
Link to comment
Share on other sites

I don't like external libraries. Notably when you use only 2 classes over a whole library. You have to refer on the library javadoc to understand what it does, or what you can do. So I prefer to rely on personal implementations, stored on "commons" package (the only thing russians do fine). Plus IntIntHolder doesn't replace TInt stuff. It just provides most used exotic storage (used 10+ times).

 

Plus, it's a matter of 10mo RAM save for the integrality of List<Integer> and Map<Integer, Integer>. Not worth the point to remember to use Trove.

 

---

 

Access, define your XML structure first, it will normally give you hints about how to load stuff, what variables you need, etc. Create each class accordingly. What's supposed to be owner on MapData ?

 

Imagine the xml structure i made is like this:

 

 

<Map id="1" mapName="Hello">

       <Owner ="Blue" x="553" y="5353" z="52352">

       <Owner ="Red" x="553" y="5353" z="52352">

</Map>

 

Something like this.

 

The code i made is this:

private final Map<Integer, Data> _eventData = new FastMap<Integer, Data>();	
	private final Map<Integer, MapData> maps = new FastMap<Integer, MapData>();
	
	public class Data
	{
		private Map<Integer, MapData> _map = new FastMap<Integer, MapData>();
		
		private Data(Map<Integer, MapData> map)
		{
			_map = map;
		}
		
		public MapData getMapById(int id)
		{
			return maps.get(id);
		}
	}
	
	public class MapData
	{
		private String _mapName;
		private FastMap<String, int[]> _Locations;
		
		private MapData(String mapName, FastMap<String, int[]> locations)
		{
			_mapName = mapName;
			_Locations = locations;
		}
		
		public int[] getMapLocationByOwner(String owner)
		{
			int[] loc = null;
			
			if (_Locations.containsKey(owner))
				loc = _Locations.get(owner);
			else
				System.out.print("Error: Can't find location for owner");
		
			return loc;
		}
		
		public String getMapName()
		{
			return _mapName;
		}
	}


	/**
	 * @param String mapName
	 * @param Array ArrayList<int[]>
	 */
	public void addNewMap(int eventId, int mapid,  String mapName, FastMap<String, int[]> fastmap)
	{
		MapData mapData = new MapData(mapName, fastmap);
		Map<Integer, MapData> map = new FastMap<Integer,MapData>(); 
		map.put(mapid, mapData);
		Data data = new Data(map);
		_eventData.put(eventId, data);
	}
	
	/**
	 * 
	 * @param id ~> Event ID
	 * @return Return Map Data base on Event ID
	 */
	public Data getMapByEventId(int id)
	{
		if (_eventData.containsKey(id))
			return	_eventData.get(id);
		else
			System.out.print("Error: Map not found for event ID: " + id);
		
		return null;			
	}

But for some reason it hits at "Map not found for event ID" idk why .. 

Link to comment
Share on other sites

Are you aware you must parse your XML ? XMLDocumentFactory.getInstance().loadDocument on aCis. Also, are you aware than with XML you can do things like this (notably useful when you got redundant data) :

<owner type="red">
    <location x="" y="" z="" />
    <location x="" y="" z="" />
    <location x="" y="" z="" />
</owner>
<owner type="blue">
    <location x="" y="" z="" />
    <location x="" y="" z="" />
</owner>

MapData simply needs a String for owner. To retrieve all maps of a owner, you have to for loop maps and filter the owner string. Or you create specific List for each team, but scalability will suck in case you want to add a third or fourth faction.

 

About XML parsing, refer to any datatables. Still.

Link to comment
Share on other sites

Are you aware you must parse your XML ? XMLDocumentFactory.getInstance().loadDocument on aCis. Also, are you aware than with XML you can do things like this (notably useful when you got redundant data) :

<owner type="red">
    <location x="" y="" z="" />
    <location x="" y="" z="" />
    <location x="" y="" z="" />
</owner>
<owner type="blue">
    <location x="" y="" z="" />
    <location x="" y="" z="" />
</owner>

MapData simply needs a String for owner. To retrieve all maps of a owner, you have to for loop maps and filter the owner string. Or you create specific List for each team, but scalability will suck in case you want to add a third or fourth faction.

 

About XML parsing, refer to any datatables. Still.

 

I am aware of what? LEL tryskell.. afc the load is done upon parse of the xml...   :-[  :-[

Edited by AccessDenied
Link to comment
Share on other sites

That would be true, Trove library would have no purpose to exist, at least for container such as List and Map. And there would have no performance boost, either in RAM or CPU (and the RAM one was currently existing).

 

I doubt Java 8 edited anything prior to that, so you can assume he says wrong things. Fix me if I'm wrong.

 

I get it, denial is the first step. At some point you will accept it, everything in java is an object with few rare exceptions. java is far away from metal code.

 

Optimizing and talking about bullshit for a few cpu cycles makes you only stupid, L2J server will already deal with millions of objects, whats the difference if you "reduce" it by a few hundreds?

 

If we where talking about C/C++ servers then I get it, every byte counts, but in Java that should not be your concern except if you're a paranoid psycho.

 

 

Of course I am a big fun of optimized code, but you guys bring stupidity on a whole new level.

Link to comment
Share on other sites

I get it, denial is the first step. At some point you will accept it, everything in java is an object with few rare exceptions. java is far away from metal code.

 

Optimizing and talking about bullshit for a few cpu cycles makes you only stupid, L2J server will already deal with millions of objects, whats the difference if you "reduce" it by a few hundreds?

 

If we where talking about C/C++ servers then I get it, every byte counts, but in Java that should not be your concern except if you're a paranoid psycho.

 

 

Of course I am a big fun of optimized code, but you guys bring stupidity on a whole new level.

 

No proof, only hate - couldn't expect more from you :P.

 

And that's not because everything is automatized behind than you must code like an idiot. First because you won't stuck to Java all your life, so better keep healthy coding habits. Second because even Java has a use to delay/restrain GC calls (that's computer ressources used for other things). And finally it doesn't cost you to code correctly BUT it costs you to debug a really bad coded / not scalable feature.

 

And hundreds + thousand + hundred... All accumulated you got your million saved objects, one day or another. With Java it can go pretty fast...

 

And I'm far to be a optimizer... Old L2J guys were fond of primitive arrays. I would be a optimizer I would replace every single container and create my own, etc. And anyway you're irrelevant with the whole thread - like almost 90% of your answers. Which will end with a topic lock because of your nonsense. But you know better than me for sure.

Link to comment
Share on other sites

No proof, only hate - couldn't expect more from you :P.

 

And that's not because everything is automatized behind than you must code like an idiot. First because you won't stuck to Java all your life, so better keep healthy coding habits. Second because even Java has a use to delay/restrain GC calls (that's computer ressources used for other things). And finally it doesn't cost you to code correctly BUT it costs you to debug a really bad coded / not scalable feature.

 

And hundreds + thousand + hundred... All accumulated you got your million saved objects, one day or another. With Java it can go pretty fast...

 

And I'm far to be a optimizer... Old L2J guys were fond of primitive arrays. I would be a optimizer I would replace every single container and create my own, etc. And anyway you're irrelevant with the whole thread - like almost 90% of your answers. Which will end with a topic lock because of your nonsense. But you know better than me for sure.

 

 

I believe I do, I've edited java on bytecode level in the past and also worked with unsafe for specific projects to squeeze the most out of them, and I have a hands-on experience with what java can do and how it does it. As for my irrelevant answers thats probably because the content of the topics don't satisfy the low-end of my standards and I don't take them seriously, excuse me for that, that's just me.

 

Don't blame me for nonsense and locked topics, makes you look stupider than you actually are.

 

 

This is no scientific topic neither real professionals/programmers exist on this forum, so proofs are science-fiction, I mainly code in Java and I love it, but at least I accept its cons (fake templates, overheads) and that makes me a better programmer, I use the right tool at the right time, its not just Java 

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now



×
×
  • Create New...