Community

Hi, i'm want to implement a custom List in anylogic. I'm modelling a router on a network and i want to store the incoming packets in a internal queue of the router object, which should behave as a priority queue. I implemented a own "Packet" and "PacketList" class. My problem is now that i cant use a collection variable since Anylogic just supports LinkedList and ArrayList. I tried to use a plain variable of type "PacketList" and use "new PacketList();" as initial value but it dont work, i get a NullPointerException when trying to access the List. Does somebody knows how to properly initialize this variable or may be my approach is wrong? regards
to Enguerrand: You could use either a Collection Variable or a Plain Variable. For instance, to create a Collection Variable with your own list type, you should simply print the name of this class in the field "Collection Class".
Thanks Victor for your helpfull answer. I would also know how to do this with a plain variable, since when i use a plain variabe and "new PacketList()" as initial value i get a NullPointerException. regards
to Enguerrand: To create a collection using a Plain Variable, you should specify its type, that is select Java Class option and print "PacketList" in the field next to the option. A NullPointerException shouldn't occur in that case. When do you get it?
to Victor: I didn't investigate it any further, since i wasn't sure that it was the right way to do it. If it is so, then the problem was somewhere else. Many thanks for your answers regards