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
Victor Gleim — 21.11.07
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".
Enguerrand Dibanda — 21.11.07
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
Victor Gleim — 22.11.07
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?
Enguerrand Dibanda — 22.11.07
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