Dragonfly Q&A

Questions about ObjectList and ObjectListIterator

0 like 0 dislike
Hi, I just had a couple of question about how the ObjectList and ObjectListIterator class work.

<p>1. Are the objects in ObjectList kept at the front of the array or are they allowed to be scattered throughout the list due to deletions of objects in the middle of the list?

<p>2. Does the ObjectListIterator get an Object pointer from the private list or should we add a function in Object list to recieve the pointer when calling currentObject()? Ex. Right now I use the index I am at in ObjectListIterator to retrieve the object straight from array.
Dragonfly version v4.0, Checkpoint #3
asked Sep 8, 2015 in Engine Development by yahelnachum

1 Answer

0 like 0 dislike
1) Since the list is kept as an array, when an Object is removed from the list, any following items should be "scooted down" to remove the vacated space in the array.  See the remove() method in Listing 4.27 (book version 3) that illustrates this for an IntList.

<p>

2) The ObjectListIterator is a friend of ObjectList.  As such, it has access to the private attributes of ObjectList.  ObjectListIterator keeps an index, representing where it is in iterating through the list.  This allows currentObject() to immediately return the object at spot index (e.g., list[index]). See currentItem() in Listing 4.29 (book version 3) for an example.
answered Sep 9, 2015 by claypool
More information about Dragonfly can be found on the Dragonfly Home Page.
...