Falcon::ItemList Class Reference

List of Falcon items. More...

#include <itemlist.h>

Inheritance diagram for Falcon::ItemList:

Inheritance graph
[legend]

List of all members.

Public Member Functions

virtual void append (const Item &itm)
 Append an item at the end of the sequence.
virtual const Itemback () const
 Gets the last item in the list.
virtual void clear ()
 Removes all the elements in the list.
virtual FalconDataclone () const
 Deletes the list.
virtual bool empty () const
 Tells if the list is empty.
ItemListElementerase (ItemListElement *elem)
 Remove given element.
ItemListElementfirst () const
 Gets the pointer to the first element for list traversal.
virtual const Itemfront () 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.
ItemListElementlast () 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 ItemgetCurrent (const Iterator &iter)
virtual ItemgetCurrentKey (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


Detailed Description

List of Falcon items.

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.


Constructor & Destructor Documentation

Falcon::ItemList::ItemList (  )  [inline]

Builds an empty list.

Falcon::ItemList::ItemList ( const ItemList l  ) 

Clones a list.

virtual Falcon::ItemList::~ItemList (  )  [inline, virtual]


Member Function Documentation

virtual void Falcon::ItemList::append ( const Item data  )  [inline, virtual]

Append an item at the end of the sequence.

Implements Falcon::Sequence.

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.

Returns:
a reference to the last item in the list or a spectacular crash.

Implements Falcon::Sequence.

virtual void Falcon::ItemList::clear (  )  [virtual]

Removes all the elements in the list.

Implements Falcon::Sequence.

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.

Note:
The base version of this function just adds the iterator to the iterator list; it MUST be called by all the implementations.

Reimplemented from Falcon::Sequence.

Reimplemented in Falcon::CoreSlot.

virtual bool Falcon::ItemList::empty (  )  const [inline, virtual]

Tells if the list is empty.

Returns:
true if the list is empty.

Implements Falcon::Sequence.

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.

Parameters:
iter an iterator (possibly invalid or not generated by this class).
Returns:
true if the iterator was valid for this object.

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.

Parameters:
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.

Returns:
the pointer to the first element pointer, or 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.

Returns:
a reference to the first item in the list or a spectacular crash.

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.

virtual Item& Falcon::ItemList::getCurrent ( const Iterator iter  )  [protected, virtual]

Implements Falcon::Sequence.

virtual Item& Falcon::ItemList::getCurrentKey ( const Iterator iter  )  [protected, virtual]

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.

Note:
The base version of this function just adds the iterator to the iterator list; it MUST be called by all the implementations.
Parameters:
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.

virtual void Falcon::ItemList::insert ( Iterator iter,
const Item data 
) [protected, virtual]

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.

Parameters:
iterator an iterator.
data the item to be inserted
Returns:
true if the iterator was valid for this object.

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.

Parameters:
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.

Returns:
the pointer to the last element pointer, or 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]

Prepend an item at the beginning of the sequence.

Implements Falcon::Sequence.

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.

Parameters:
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.

Parameters:
itm the item to be pushed.

uint32 Falcon::ItemList::size (  )  const [inline]

Return the number of the items in the list.

Returns:
count of items in the list


The documentation for this class was generated from the following file:

Generated on Mon Oct 19 10:11:37 2009 for Falcon_Core by  doxygen 1.5.8