Index

DKSequentialCollection

Purpose:

DKSequentialCollection is a collection, a subclass of dkCollection, which supports sorting and sequential access in a bidirectional manner. A sequential collection cannot evaluate a query. DKSequentialCollection can create and support DKSequentialIterator, which is also bidirectional.

Class summary:

class DKSequentialCollection: public dkCollection
{
public:
 
   DKSequentialCollection(); 
   virtual DKSequentialCollection();
   virtual unsigned long cardinality();
   virtual dkIterator *createIterator();
 
   virtual DKAny* retrieveElementAt(dkIterator& where);
   virtual void addElement(const DKAny& element);
   virtual void insertElementAt(const DKAny& element, 
                                dkIterator& where);
   virtual void replaceElementAt(const DKAny& element, 
                                 dkIterator& where);
   virtual void removeElementAt(dkIterator& where);
   virtual void removeAllElements();
   virtual void sort(DKBoolean ascOrder = TRUE);
   virtual void sort(dkSort* sortFunction, 
                     DKBoolean ascOrder = TRUE);
   virtual void setSortFunction(dkSort* sortFcn);
   virtual dkSort* getSortFunction() const; 
   virtual dkDataObjectBase*getOwner(); 
   virtual DKString getAssociatedAttrName(); 
};
 

Members:

Member functions

cardinality
Returns the number of elements in a collection.
virtual unsigned long cardinality();

retrieveElementAt
Returns the element that the iterator is pointing at.
virtual DKAny* retrieveElementAt(dkIterator& where);

createIterator
Creates a new iterator for this collection, which is a DKSequentialIterator object.
virtual dkIterator *createIterator();

addElement
Adds an element to the collection, and invalidates all the current iterators.
virtual void addElement(const DKAny& element);

insertElementAt
Adds a new element, after the element the iterator is currently pointing to. The iterator is advanced to the new element, invalidating all other iterators.
virtual void insertElementAt(const DKAny& element, 
                             dkIterator& where) = 0;

replaceElementAt
Replaces the element the iterator is currently pointing at.
virtual void replaceElementAt(const DKAny& element, 
                              dkIterator& where) = 0;

removeElementAt
Removes the element the iterator is currently pointing at. The iterator is automatically advanced to the next element after this operation, invalidating all other iterators.
virtual void removeElementAt(dkIterator& where) = 0;

removeAllElements
Removes all elements in the collection, and invalidates all other iterators.
virtual void removeAllElements() = 0;

apply
Executes a caller-supplied function on every element in the collection. This method is often used to destroy the data portion of the elements before the collection is destroyed; this is because the collection elements are DKAny objects, and their destructors only destroy objects of which storage is managed by DKAny.
virtual void apply(void (*function)(DKAny& ));

sort
Sorts the elements in the collection. sortFunction is a function object which defines the method to get the object key, compare two keys, etcetera, for objects in this collection. ascOrder is the desired order. The default order is TRUE, which means to sort in ascending order. You must provide a subclass of the dkSort class. This subclass of the dkSort class will determine how the objects are to be compared.
virtual void sort(DKBoolean ascOrder = TRUE); 

virtual void sort(dkSort* sorFuntion, DKBoolean ascOrder = TRUE);

setSortFunction
Sets the sort function for sorting this collection. You must provide a subclass of the dkSort class. This subclass of the dkSort class will determine how the objects are to be compared.
virtual void setSortFunction(dkSort* sortFcn);

getSortFunction
Gets the sort function. Gets the sort function (class implementing the dkSort interface) if any has been specified.
virtual dkSort* getSortFunction() const;

getOwner
Gets the owner data object for this collection. Gets the owner data object for this collection if this collection belongs to one.
virtual dkDataObjectBase* getOwner() = 0;

getAssociatedAttrName
Gets the associated attribute name.
virtual DKString getAssociatedAttrName() = 0;

(c) Copyright International Business Machines Corporation 1996, 2003. IBM Corp. All rights reserved.