Dillo v3.1.1-14-g8f67d6e0
Loading...
Searching...
No Matches
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.
 
void remove (int pos)
 
object::Objectget (int pos) const
 
void clear ()
 
void sort (object::Comparator *comparator=&object::standardComparator)
 Sort the elements in the vector.
 
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.
 
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.
 
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.
 
virtual bool equals (Object *other)
 Returns, whether two objects are equal.
 
virtual int hashValue ()
 Return a hash value for the object.
 
virtual Objectclone ()
 Return an exact copy of the object.
 
const char * toString ()
 Use object::Object::intoStringBuffer to return a textual representation of the object.
 
virtual size_t sizeOf ()
 Return the number of bytes, this object totally uses.
 

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.

Definition at line 124 of file container.hh.

Constructor & Destructor Documentation

◆ Vector()

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

Definition at line 105 of file container.cc.

References array, DBG_OBJ_CREATE, numAlloc, numElements, and ownerOfObjects.

◆ ~Vector()

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

Definition at line 115 of file container.cc.

References array, clear(), and DBG_OBJ_DELETE.

Member Function Documentation

◆ bsearch() [1/2]

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()).

Definition at line 222 of file container.cc.

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

Referenced by bsearch(), and insertSorted().

◆ bsearch() [2/2]

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

Definition at line 176 of file container.hh.

References bsearch(), and size().

◆ clear()

void lout::container::untyped::Vector::clear ( )

Definition at line 159 of file container.cc.

References array, numElements, and ownerOfObjects.

Referenced by lout::container::untyped::List::~List(), and ~Vector().

◆ createIterator()

Collection0::AbstractIterator * lout::container::untyped::Vector::createIterator ( )
protectedvirtual

Implements lout::container::untyped::Collection0.

Definition at line 289 of file container.cc.

◆ get()

object::Object * lout::container::untyped::Vector::get ( int  pos) const
inline

Definition at line 170 of file container.hh.

References array, and numElements.

◆ insert()

void lout::container::untyped::Vector::insert ( object::Object newElement,
int  pos 
)

Definition at line 170 of file container.cc.

References array, numAlloc, numElements, and put().

Referenced by insertSorted().

◆ 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.

Definition at line 163 of file container.hh.

References bsearch(), and insert().

◆ put()

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

Definition at line 128 of file container.cc.

References array, numAlloc, numElements, and ownerOfObjects.

Referenced by insert().

◆ remove()

void lout::container::untyped::Vector::remove ( int  pos)

Definition at line 193 of file container.cc.

References array, numElements, and ownerOfObjects.

◆ size()

int lout::container::untyped::Vector::size ( )
virtual

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

Definition at line 123 of file container.cc.

References numElements.

Referenced by bsearch(), and bsearch().

◆ sort()

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

Sort the elements in the vector.

Assumes that all elements are Comparable's.

Definition at line 207 of file container.cc.

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

Friends And Related Symbol Documentation

◆ VectorIterator

friend class VectorIterator
friend

Definition at line 126 of file container.hh.

Member Data Documentation

◆ array

object::Object** lout::container::untyped::Vector::array
private

◆ numAlloc

int lout::container::untyped::Vector::numAlloc
private

Definition at line 130 of file container.hh.

Referenced by insert(), put(), and Vector().

◆ numElements

◆ ownerOfObjects


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