Dillo
Classes | Public Member Functions | Protected Member Functions | Private Attributes | Friends | List of all members
lout::container::untyped::Vector Class Reference

Container, which is implemented by an array, which is dynamically resized. More...

#include <container.hh>

Classes

class  VectorIterator
 

Public Member Functions

 Vector (int initSize, bool ownerOfObjects)
 
 ~Vector ()
 
int size ()
 
void put (object::Object *newElement, int newPos=-1)
 
void insert (object::Object *newElement, int pos)
 
int insertSorted (object::Object *newElement, object::Comparator *comparator=&object::standardComparator)
 Insert into an already sorted vector. More...
 
void remove (int pos)
 
object::Objectget (int pos) const
 
void clear ()
 
void sort (object::Comparator *comparator=&object::standardComparator)
 
int bsearch (Object *key, bool mustExist, int start, int end, object::Comparator *comparator=&object::standardComparator)
 Use binary search to find an element in a sorted vector. More...
 
int bsearch (Object *key, bool mustExist, object::Comparator *comparator=&object::standardComparator)
 
- Public Member Functions inherited from lout::container::untyped::Collection
void intoStringBuffer (misc::StringBuffer *sb)
 Store a textual representation of the object in a misc::StringBuffer. More...
 
Iterator iterator ()
 
- Public Member Functions inherited from lout::object::Object
virtual ~Object ()
 The destructor is defined as virtual (but not abstract), so that destruction of Object's works properly. More...
 
virtual bool equals (Object *other)
 Returns, whether two objects are equal. More...
 
virtual int hashValue ()
 Return a hash value for the object. More...
 
virtual Objectclone ()
 Return an exact copy of the object. More...
 
const char * toString ()
 Use object::Object::intoStringBuffer to return a textual representation of the object. More...
 
virtual size_t sizeOf ()
 Return the number of bytes, this object totally uses. More...
 

Protected Member Functions

AbstractIteratorcreateIterator ()
 

Private Attributes

object::Object ** array
 
int numAlloc
 
int numElements
 
bool ownerOfObjects
 

Friends

class VectorIterator
 

Detailed Description

Container, which is implemented by an array, which is dynamically resized.

Constructor & Destructor Documentation

lout::container::untyped::Vector::Vector ( int  initSize,
bool  ownerOfObjects 
)

References DBG_OBJ_CREATE.

lout::container::untyped::Vector::~Vector ( )

References DBG_OBJ_DELETE.

Member Function Documentation

int lout::container::untyped::Vector::bsearch ( Object key,
bool  mustExist,
int  start,
int  end,
object::Comparator comparator = &object::standardComparator 
)

Use binary search to find an element in a sorted vector.

If "mustExist" is true, only exact matches are found; otherwise, -1 is returned. If it is false, the position of the next greater element is returned, or, if the key is the greatest element, the size of the array. (This is the value which can be used for insertion; see insertSortet()).

References lout::object::Comparator::compare(), DBG_OBJ_MSG, DBG_OBJ_MSG_END, DBG_OBJ_MSG_START, and DBG_OBJ_MSGF.

Referenced by bsearch(), and insertSorted().

int lout::container::untyped::Vector::bsearch ( Object key,
bool  mustExist,
object::Comparator comparator = &object::standardComparator 
)
inline

References bsearch(), and size().

void lout::container::untyped::Vector::clear ( )
Collection0::AbstractIterator * lout::container::untyped::Vector::createIterator ( )
protectedvirtual
object::Object* lout::container::untyped::Vector::get ( int  pos) const
inline
void lout::container::untyped::Vector::insert ( object::Object newElement,
int  pos 
)

Referenced by insertSorted().

int lout::container::untyped::Vector::insertSorted ( object::Object newElement,
object::Comparator comparator = &object::standardComparator 
)
inline

Insert into an already sorted vector.

Notice that insertion is not very efficient, unless the position is rather at the end.

References bsearch(), and insert().

void lout::container::untyped::Vector::put ( object::Object newElement,
int  newPos = -1 
)
void lout::container::untyped::Vector::remove ( int  pos)
int lout::container::untyped::Vector::size ( )
virtual

Implements lout::container::untyped::Collection.

Referenced by bsearch().

void lout::container::untyped::Vector::sort ( object::Comparator comparator = &object::standardComparator)

Sort the elements in the vector. Assumes that all elements are Comparable's.

References lout::object::Comparator::compareFun(), and lout::object::Comparator::compareFunComparator.

Friends And Related Function Documentation

friend class VectorIterator
friend

Member Data Documentation

object::Object** lout::container::untyped::Vector::array
private
int lout::container::untyped::Vector::numAlloc
private
int lout::container::untyped::Vector::numElements
private
bool lout::container::untyped::Vector::ownerOfObjects
private

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