#include <itemlist.h>
Public Member Functions | |
virtual void | append (const Item &itm) |
Append an item at the end of the sequence. | |
virtual const Item & | back () const |
Gets the last item in the list. | |
virtual void | clear () |
Removes all the elements in the list. | |
virtual FalconData * | clone () const |
Deletes the list. | |
virtual bool | empty () const |
Tells if the list is empty. | |
ItemListElement * | erase (ItemListElement *elem) |
Remove given element. | |
ItemListElement * | first () const |
Gets the pointer to the first element for list traversal. | |
virtual const Item & | front () const |
Gets the first item in the list. | |
virtual void | gcMark (uint32 mark) |
Perform marking of items stored in the list. | |
void | insert (ItemListElement *elem, const Item &item) |
Insert an item after given before given element. | |
ItemList (const ItemList &l) | |
Clones a list. | |
ItemList () | |
Builds an empty list. | |
ItemListElement * | last () const |
Gets the pointer to the last element for list traversal. | |
virtual bool | onCriterion (Iterator *elem) const |
Criterion called back by disposeIteratorOnCriterion(). | |
void | pop_back () |
Removes the last element from the list. | |
void | pop_front () |
Removes the first element from the list. | |
virtual void | prepend (const Item &itm) |
Prepend an item at the beginning of the sequence. | |
void | push_back (const Item &itm) |
Pushes a shallow copy of the item to the end of the list. | |
void | push_front (const Item &itm) |
Pushes a shallow copy of the item in front of the list. | |
uint32 | size () const |
Return the number of the items in the list. | |
virtual | ~ItemList () |
Protected Member Functions | |
virtual void | copyIterator (Iterator &tgt, const Iterator &source) const |
Copy an iterator so that the two points to the same item. | |
virtual bool | equalIterator (const Iterator &first, const Iterator &second) const |
virtual void | erase (Iterator &iter) |
Deletes the element at position indicated by the iterator. | |
virtual Item & | getCurrent (const Iterator &iter) |
virtual Item & | getCurrentKey (const Iterator &iter) |
virtual void | getIterator (Iterator &tgt, bool tail=false) const |
Gets an Iterator valid for this sequence. | |
virtual bool | hasCurrent (const Iterator &iter) const |
virtual bool | hasNext (const Iterator &iter) const |
virtual bool | hasPrev (const Iterator &iter) const |
virtual void | insert (Iterator &iter, const Item &data) |
Inserts an element in a position indicated by the iterator. | |
virtual bool | next (Iterator &iter) const |
virtual bool | prev (Iterator &iter) const |
This class is designed to work together with Falcon object as a UserData, but it can be also used for other reasons, when an Array is not the best way to represent data.
Falcon::ItemList::ItemList | ( | ) | [inline] |
Builds an empty list.
Falcon::ItemList::ItemList | ( | const ItemList & | l | ) |
Clones a list.
virtual Falcon::ItemList::~ItemList | ( | ) | [inline, virtual] |
virtual void Falcon::ItemList::append | ( | const Item & | data | ) | [inline, virtual] |
virtual const Item& Falcon::ItemList::back | ( | ) | const [virtual] |
Gets the last item in the list.
If the list is empty, you will crash, so use this only when the list is NOT empty.
Implements Falcon::Sequence.
virtual void Falcon::ItemList::clear | ( | ) | [virtual] |
virtual FalconData* Falcon::ItemList::clone | ( | ) | const [virtual] |
Deletes the list.
Items are shallowly destroyed.
Implements Falcon::FalconData.
Reimplemented in Falcon::CoreSlot.
virtual void Falcon::ItemList::copyIterator | ( | Iterator & | tgt, | |
const Iterator & | source | |||
) | const [protected, virtual] |
Copy an iterator so that the two points to the same item.
The source iterator may point to the past-end element, but must not be invalid.
Reimplemented from Falcon::Sequence.
Reimplemented in Falcon::CoreSlot.
virtual bool Falcon::ItemList::empty | ( | ) | const [inline, virtual] |
virtual bool Falcon::ItemList::equalIterator | ( | const Iterator & | first, | |
const Iterator & | second | |||
) | const [protected, virtual] |
Implements Falcon::Sequence.
virtual void Falcon::ItemList::erase | ( | Iterator & | iter | ) | [protected, virtual] |
Deletes the element at position indicated by the iterator.
The implementation must check that the iterator is a valid iterator created by this object and pointing to a valid position.
Deletion happens at given position, shifting all the remaining elements backward; after a successful erase, the iterator must point to the element that was previously next in the series, or must be invalidated if the removed element was the last.
If the sequence is empty or the iterator is invalid, an AccessError must be thrown. If the iterator is referencing another sequence, a CodeError must be thrown.
iter | an iterator (possibly invalid or not generated by this class). |
Implements Falcon::Sequence.
ItemListElement* Falcon::ItemList::erase | ( | ItemListElement * | elem | ) |
Remove given element.
If this is the last element of the list, the method returns 0, else it return the element that was following the delete element in the list, and that now has its place.
elem | an element from this list (or you'll witness psychedelic crashes) |
ItemListElement* Falcon::ItemList::first | ( | ) | const |
Gets the pointer to the first element for list traversal.
The list element is just an item with previous and next pointers. If the list is empty, this method will return 0.
virtual const Item& Falcon::ItemList::front | ( | ) | const [virtual] |
Gets the first item in the list.
If the list is empty, you will crash, so use this only when the list is NOT empty.
Implements Falcon::Sequence.
virtual void Falcon::ItemList::gcMark | ( | uint32 | mark | ) | [virtual] |
Perform marking of items stored in the list.
Reimplemented from Falcon::Sequence.
Reimplemented in Falcon::CoreSlot.
Implements Falcon::Sequence.
Implements Falcon::Sequence.
virtual void Falcon::ItemList::getIterator | ( | Iterator & | tgt, | |
bool | tail = false | |||
) | const [protected, virtual] |
Gets an Iterator valid for this sequence.
If you need an iterator as a pointer or in the target stack, use Iterator( Sequence*, bool) instead.
The iterator constructor calls back this method to be configured.
It is possible to call this method thereafter to reset the iterator, even if it's gone invalid.
However, it is not legal to call this method with an iterator coming from another sequence; this will cause the program to throw a CodeError.
An | Iterator to be set. | |
tail | if false, get an iterator to the first element, else get an iterator to the last element. |
Reimplemented from Falcon::Sequence.
Reimplemented in Falcon::CoreSlot.
virtual bool Falcon::ItemList::hasCurrent | ( | const Iterator & | iter | ) | const [protected, virtual] |
Implements Falcon::Sequence.
virtual bool Falcon::ItemList::hasNext | ( | const Iterator & | iter | ) | const [protected, virtual] |
Implements Falcon::Sequence.
virtual bool Falcon::ItemList::hasPrev | ( | const Iterator & | iter | ) | const [protected, virtual] |
Implements Falcon::Sequence.
Inserts an element in a position indicated by the iterator.
The implementation must check that the iterator is a valid iterator created by this object and pointing to a valid position.
Insertion happens at given position, shifting all the remaining elements forward; after a successful insert, the iterator must point to the newly inserted element, and the previously current element is found safely in the next() position of the iterator.
Valid iterators (generated by this owner) pointing to invalid positions must be treated as pointing to last-past-one element; insertion causes append on tail, and at return they must be valid and point to the last valid element (the one just inserted).
If the iterator cannot be used, for example because their owner is not this item, this method will raise a CodeError.
iterator | an iterator. | |
data | the item to be inserted |
Implements Falcon::Sequence.
void Falcon::ItemList::insert | ( | ItemListElement * | elem, | |
const Item & | item | |||
) |
Insert an item after given before given element.
To insert an item past the last element, use 0 as element pointer (last->next); this will work also to insert an item in an empty list.
elem | the element before which to insert the item, or 0 to apped at tail. | |
item | the item to be inserted. |
ItemListElement* Falcon::ItemList::last | ( | ) | const |
Gets the pointer to the last element for list traversal.
The list element is just an item with previous and next pointers. If the list is empty, this method will return 0.
virtual bool Falcon::ItemList::next | ( | Iterator & | iter | ) | const [protected, virtual] |
Implements Falcon::Sequence.
virtual bool Falcon::ItemList::onCriterion | ( | Iterator * | elem | ) | const [virtual] |
Criterion called back by disposeIteratorOnCriterion().
Return true to remove this iterator, false to let it alive. Disposed iterators are removed from the iterator list of this sequence and invalidated.
Reimplemented from Falcon::Sequence.
void Falcon::ItemList::pop_back | ( | ) |
Removes the last element from the list.
The item is shallowly removed. Deep content will be reclaimed through GC. Calling pop_back() on an empty list will have no effect.
void Falcon::ItemList::pop_front | ( | ) |
Removes the first element from the list.
The item is shallowly removed. Deep content will be reclaimed by GC. Calling pop_front() on an empty list will have no effect.
virtual void Falcon::ItemList::prepend | ( | const Item & | data | ) | [inline, virtual] |
virtual bool Falcon::ItemList::prev | ( | Iterator & | iter | ) | const [protected, virtual] |
Implements Falcon::Sequence.
void Falcon::ItemList::push_back | ( | const Item & | itm | ) |
Pushes a shallow copy of the item to the end of the list.
itm | the item to be pushed. |
void Falcon::ItemList::push_front | ( | const Item & | itm | ) |
Pushes a shallow copy of the item in front of the list.
itm | the item to be pushed. |
uint32 Falcon::ItemList::size | ( | ) | const [inline] |
Return the number of the items in the list.