Jump to content

Recommended Posts

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.

 

Well it was trashcode anyway i wanted show you the style even the shared was for previous use i removed them anyway.

 

Btw is there any way to contact you via skype or something i want show you the code in private, cause many kids like Napster321ॐ who buy apple computers. 

It ended up 150 lines it's basicaly 3 HMs and 2 Ssets. 

 

Mostly i care for the design pattern, ill pay attention on how fast it is afterwards.

Thanks for attention.

Posted

Gosling would commit suicide if for some reason see this section... :lol:

Why ? It's suggestion for a stucture, mostly like advice e.t.c Why someone would have a problem when someone asking an advice. 

I suicide everyday watching kids beggin for premade codes lel 

Posted (edited)

What's your problem with FastList ? It's not because you write SuperFastList then it will be faster than FastList. FastList is similar to a LinkedList, it is way slower/fatter than a ArrayList. Same for Maps.

 

Stop to use that container, ffs.

 

---

 

As I said, you misconcept Java structure. Try to analyze an existing "holding object" and "table". I named few of them, but basically the whole datatables package is full of those. According to you why on L2J you haven't .get.get.get scenarios ? Think a little about it. That's not because you code complex things and L2J doesn't. It simply because you take the wrong path doing it.

 

Write and define each class informations before trying to develop. You just waste your time coding crap actually.

 

Finally a .get() will return null if not found. So you can simply write following without any trouble :

public MapData getMapById(int id)
{
    return _map.get(id);
}

I invite you to read my previous answer over and over until you get it, because I doubt you will find a better explanation.

Edited by Tryskell
Posted (edited)

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.

 

Sorry but 99% of java primitives are fake primitives and/or are wrapped every time into Integer objects in java internally in most cases. Yeah also java has so much more features that die right after the compilation and developers never know until they learn to read bytecode. Java doesn't run on the metal and even "when" it does throught the the JIT you still have the memory overhead of the objects, everything is an object until its interpreted by the VM, and most likely even "primitives"

 

PS: int.class

Edited by xxdem
Posted

Why ? It's suggestion for a stucture, mostly like advice e.t.c Why someone would have a problem when someone asking an advice. 

I suicide everyday watching kids beggin for premade codes lel

 

I suggest you to read some book about algorithms and data structures. You will see that there is no magic in HashMap, FastMap, etc, etc. :lol:
Posted

Sorry but 99% of java primitives are fake primitives and/or are wrapped every time into Integer objects in java internally in most cases.

 

PS: int.class

Do you mean that in 99% of cases Integer is made instead of int? In what cases actually?

Posted (edited)

Do you mean that in 99% of cases Integer is made instead of int? In what cases actually?

 

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.

Edited by Tryskell
Posted (edited)

What's your problem with FastList ? It's not because you write SuperFastList then it will be faster than FastList. FastList is similar to a LinkedList, it is way slower/fatter than a ArrayList. Same for Maps.

 

Stop to use that container, ffs.

 

---

 

As I said, you misconcept Java structure. Try to analyze an existing "holding object" and "table". I named few of them, but basically the whole datatables package is full of those. According to you why on L2J you haven't .get.get.get scenarios ? Think a little about it. That's not because you code complex things and L2J doesn't. It simply because you take the wrong path doing it.

 

Write and define each class informations before trying to develop. You just waste your time coding crap actually.

 

Finally a .get() will return null if not found. So you can simply write following without any trouble :

public MapData getMapById(int id)
{
    return _map.get(id);
}

I invite you to read my previous answer over and over until you get it, because I doubt you will find a better explanation.

 

I did read every answer you did, i'm taking ideas i did what you said but it need some work when it come in such a structure program to avoid mistakes.

One of the problems i face is when u load the values from xml to pass them on the structure it's kinda confusing 

 

everytime xml load lets say "Map"

it take the Map ID and the next value the Map Name so afterwards idk what exactly should i do, make directly a hashmap and bla bla thats where i stuck and i work on.

Sound kinda funny but i'm sure all had problems like this :P but at least it worked until now by 75% since last time that i made it with HM into HM into HM -.-  oh god.. trashcode ftw.

 

Also dafaq with this HashMap it replace the key if its the same, it need also an index.. cause if i make a template (statset Map) for event 1 and then another one (Statset Map) for event 1

the new one will replace the old.. 

 

 

What the data you want to FAST store? Post here all properties.

 

There is no specific data i want store, take example Nexus Engine. 

It store all maps and it's locations in sql as:

 

Map: Giran Castle town

Locations: team1,5921,512-295;team2,952,5982-1295; 

Rewards: winner,57,10000;

e.t.c

 

Basically it make everytime a connection as i saw from the jar. I don't want this, i want avoid connections and raw maps as i mentionted before  map into map into map and i want extend this by using Stats set

 

Now as tryskell said i did some mistakes for ex using Javolution which is slower but it can be replaced afterwards unless i want trim list which i should use arraylist from the begin. 

But generally the structure would be like this:

 

Event ID (int) -> HashMap <Integer, Statssets>

     * Map ID (int) -> HashMap <Integer, Statsets>

     * Map Name (String)

                * Owner Name (String) -> HashMap <String, ArrayList<int[]>>

                * Location (int[])

      * Colors <HashMap <Integer, HashMap<String, int>>

                * Owner name (String)

                * Owner color (int)

 

This is a structure for example i try to follow, basicaly you call the owner by his name example   int[] loc = Data.getEvent(1).getMap(2).getPosition("RedTeam");

which can be really easy to used. 

 

The problem is that i'm not really familiar with such a structure. The code i posted yesterday as i said its trashcode i made a new one which it works and it has the proper checks 

and afcourse as tryskell said sometimes it return null cause lets be honest.. if you're data does not contain team 3 and u call 3 team then what u expect from the engine to do? Generate a team?

Afcourse you have to becareful a bit. As i said i did a code which it works and i tested it (replaced or FL with AL) and i removed it and redesign it again  but i always come up with some problems in the design pattern.

I don't have problem in coding, coding is so easy, the problem is in the design  as tryskell said again "before you start to code".

 

The reason i made this topic is for people to give some suggestion so i can take ideas and get into faster. I don't want anyone post codes i just wanted skilled people to give some advice on such a structure code

and how it can be done to make your life easier when you load the XML.

 

Already got ideas tho 

 

I suggest you to read some book about algorithms and data structures. You will see that there is no magic in HashMap, FastMap, etc, etc. :lol:

 

Yeap i know i miss this but for now i'm doing this as practice to get over with.

 

Ps. i know there is no magic in HashMap and FastMap but when you need to store some value along with a key... 

Edited by AccessDenied
Posted

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.

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?

Posted (edited)

Tryskell thats for you: 

 

Please don't be super bad and ignore FastMap i'll replace it  it's temporary.

private final Map<Integer, Data> _eventData = new FastMap<Integer, Data>();	
	private final Map<Integer, MapData> maps = new FastMap<Integer, MapData>();
	
	private 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);
		}
	}
	
	private 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[]> array)
	{
		MapData mapData = new MapData(mapName, array);
		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(1);
		else
			System.out.print("Error: Map not found for event ID: " + id);
		
		return null;			
	}

Any suggestions are welcomed. 

 

PS. FastMap will be replaced by ArrayList since is slow

Edited by AccessDenied
Posted
1. Use Event as container with properties. You get one HashMap<Integer, Event>

2. Use Map as container EventMap with properties. You get variable _maps as HashMap<Integer, EventMap> or List<EventMap>

 

Eventually, you get the fast readable data like this:

 

1. Map name - Event.getMap().getName();

2. Spawn location - Event.getMap().getSpawnTeam1();

2. Event colors - Event.getTeam(_teamId).getOwnerColor();

 

StatSet perfect only for big data. Your event system don't be use 100500 event's templates. Therefore, you should use the containers with intuitive methods. Yes, it has more code, but you get less mistakes while writting a code.

Posted

 

Map: Giran Castle town

Locations: team1,5921,512-295;team2,952,5982-1295; 

Rewards: winner,57,10000;

e.t.c

 

Event ID (int) -> HashMap <Integer, Statssets>

     * Map ID (int) -> HashMap <Integer, Statsets>

     * Map Name (String)

                * Owner Name (String) -> HashMap <String, ArrayList<int[]>>

                * Location (int[])

      * Colors <HashMap <Integer, HashMap<String, int>>

                * Owner name (String)

                * Owner color (int)

 

This is a structure for example i try to follow, basicaly you call the owner by his name example   int[] loc = Data.getEvent(1).getMap(2).getPosition("RedTeam");

	public class EventMap
	{
		private final int id;
		private final String name;
		private List<TeamDetails> teams;
		
		public static class TeamDetails
		{
			private final EventTeam team;
			private final Location[] locations;
			private final int color
		}
	}

EventMap map = Rnd.get(eventStructure.getMaps());

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

    • https://jumpshare.com/share/kIdeKALOhgtMKpBKqxpg Test Equip Armors-> FullPlate, Gloves, Legs, Chest , Boots
    • 黑色星期五 — 为您的流量提供高级福利 仅在11月28日,我们的特别促销码可为您提供13%的商店折扣。 促销码: BLACKFRIDAY (13% 折扣) 您可以通过我们的网站或 Telegram 机器人在商店购物! 有效链接: 数字商品商店(网站): 前往 商店 Telegram 机器人: 前往 – 通过 Telegram Messenger 方便访问商店。 其他服务: 虚拟号码服务: 前往 用于购买 Telegram Stars 的机器人: 前往 – 快速且优惠地在 Telegram 中购买 Stars。 SMM 面板: 前往 – 推广您的社交媒体账户。 我们向您呈现当前的 促销和特惠活动 列表,用于购买我们服务的产品和服务: 1. 您可以在首次购买时使用促销码:SOCNET(15% 折扣) 2. 获取 $1 商店余额或 10–20% 折扣 — 只需在我们网站注册后发送您的用户名,格式如下:“SEND ME BONUS, MY USERNAME IS...” — 您需要在我们的论坛帖子中写下这句话! 3. SMM 面板首次试用可获得 $1:只需在我们的网站(支持)提交主题为“Get Trial Bonus”的工单。 4. 我们的 Telegram 频道和 Stars 购买机器人每周都会举办 Telegram Stars 抽奖活动! 新闻: ➡ Telegram 频道: https://t.me/accsforyou_shop ➡ WhatsApp 频道: https://chat.whatsapp.com/K8rBy500nA73z27PxgaJUw?mode=ems_copy_t ➡ Discord 服务器: https://discord.gg/y9AStFFsrh 联系方式与支持: ➡ Telegram: https://t.me/socnet_support ➡ WhatsApp: https://wa.me/79051904467 ➡ Discord: socnet_support ➡ ✉ 邮箱: solomonbog@socnet.store
    • BLACK FRIDAY — PREMIUM BENEFITS FOR YOUR TRAFFIC Only on November 28 our special promo code gives you a 13% discount in the store. PROMO CODE: BLACKFRIDAY (13% Discount) Shop in our store on the website or via the Telegram bot! Active links: Digital goods store (Website): Go Store Telegram bot: Go – convenient access to the store via Telegram messenger. Other services: Virtual numbers service: Go Telegram bot for purchasing Telegram Stars: Go – fast and profitable purchase of stars in Telegram. SMM Panel: Go – promotion of your social media accounts. We want to present you the current list of promotions and special offers for purchasing our service's products and services: 1. You can use a promo code for your first purchase: SOCNET (15% discount) 2. Get $1 to your store balance or a 10–20% discount — just send your username after registering on our website using the following template: "SEND ME BONUS, MY USERNAME IS..." — you need to write this in our forum thread! 3. Get $1 for the first trial start of the SMM Panel: just open a ticket with the subject "Get Trial Bonus" on our website (Support). 4. Weekly Telegram Stars giveaways in our Telegram channel and in our bot for purchasing stars! News: ➡ Telegram channel: https://t.me/accsforyou_shop ➡ WhatsApp channel: https://chat.whatsapp.com/K8rBy500nA73z27PxgaJUw?mode=ems_copy_t ➡ Discord server: https://discord.gg/y9AStFFsrh Contacts and Support: ➡ Telegram: https://t.me/socnet_support ➡ WhatsApp: https://wa.me/79051904467 ➡ Discord: socnet_support ➡ ✉ Email: solomonbog@socnet.store
    • Usually, I work alone on my projects, but sometimes the work is much more than I've expected. Could you provide a price list? It would be good if we knew your price before contacting you. 
    • BLACK FRIDAY — PREMIUM BENEFITS FOR YOUR TRAFFIC Only on November 28 our special promo code gives you a 13% discount in the store. PROMO CODE: BLACKFRIDAY (13% Discount) Shop in our store on the website or via the Telegram bot! Active links: Digital goods store (Website): Go Store Telegram bot: Go – convenient access to the store via Telegram messenger. Other services: Virtual numbers service: Go Telegram bot for purchasing Telegram Stars: Go – fast and profitable purchase of stars in Telegram. SMM Panel: Go – promotion of your social media accounts. We want to present you the current list of promotions and special offers for purchasing our service's products and services: 1. You can use a promo code for your first purchase: SOCNET (15% discount) 2. Get $1 to your store balance or a 10–20% discount — just send your username after registering on our website using the following template: "SEND ME BONUS, MY USERNAME IS..." — you need to write this in our forum thread! 3. Get $1 for the first trial start of the SMM Panel: just open a ticket with the subject "Get Trial Bonus" on our website (Support). 4. Weekly Telegram Stars giveaways in our Telegram channel and in our bot for purchasing stars! News: ➡ Telegram channel: https://t.me/accsforyou_shop ➡ WhatsApp channel: https://chat.whatsapp.com/K8rBy500nA73z27PxgaJUw?mode=ems_copy_t ➡ Discord server: https://discord.gg/y9AStFFsrh Contacts and Support: ➡ Telegram: https://t.me/socnet_support ➡ WhatsApp: https://wa.me/79051904467 ➡ Discord: socnet_support ➡ ✉ Email: solomonbog@socnet.store
  • Topics

×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock