Logo Search packages:      
Sourcecode: icu version File versions  Download package

UVector32 Class Reference

#include <uvectr32.h>

Inheritance diagram for UVector32:

UObject UMemory

List of all members.

Detailed Description

Ultralightweight C++ implementation of a void* vector that is (mostly) compatible with java.util.Vector.

This is a very simple implementation, written to satisfy an immediate porting need. As such, it is not completely fleshed out, and it aims for simplicity and conformity. Nonetheless, it serves its purpose (porting code from java that uses java.util.Vector) well, and it could be easily made into a more robust vector class.

Design notes

There is index bounds checking, but little is done about it. If indices are out of bounds, either nothing happens, or zero is returned. We do avoid indexing off into the weeds.

There is detection of out of memory, but the handling is very coarse-grained -- similar to UnicodeString's protocol, but even coarser. The class contains one static flag that is set when any call to new returns zero. This allows the caller to use several vectors and make just one check at the end to see if a memory failure occurred. This is more efficient than making a check after each call on each vector when doing many operations on multiple vectors. The single static flag works best when memory failures are infrequent, and when recovery options are limited or nonexistent.

To do

Improve the handling of index out of bounds errors.

Alan Liu

Definition at line 59 of file uvectr32.h.

Public Member Functions

void addElement (int32_t elem, UErrorCode &status)
void assign (const UVector32 &other, UErrorCode &ec)
UBool contains (int32_t elem) const
UBool containsAll (const UVector32 &other) const
UBool containsNone (const UVector32 &other) const
int32_t elementAti (int32_t index) const
UBool empty (void) const
UBool ensureCapacity (int32_t minimumCapacity, UErrorCode &status)
UBool equals (const UVector32 &other) const
UBool expandCapacity (int32_t minimumCapacity, UErrorCode &status)
int32_t * getBuffer () const
virtual UClassID getDynamicClassID () const
int32_t indexOf (int32_t elem, int32_t startIndex=0) const
void insertElementAt (int32_t elem, int32_t index, UErrorCode &status)
UBool isEmpty (void) const
int32_t lastElementi (void) const
UBool operator!= (const UVector32 &other)
UBool operator== (const UVector32 &other)
int32_t peeki (void) const
int32_t * popFrame (int32_t size)
int32_t popi (void)
int32_t push (int32_t i, UErrorCode &status)
UBool removeAll (const UVector32 &other)
void removeAllElements ()
void removeElementAt (int32_t index)
int32_t * reserveBlock (int32_t size, UErrorCode &status)
UBool retainAll (const UVector32 &other)
void setElementAt (int32_t elem, int32_t index)
void setMaxCapacity (int32_t limit)
void setSize (int32_t newSize)
int32_t size (void) const
void sortedInsert (int32_t elem, UErrorCode &ec)
 UVector32 (int32_t initialCapacity, UErrorCode &status)
 UVector32 (UErrorCode &status)

Static Public Member Functions

static UClassID U_EXPORT2 getStaticClassID ()
static void U_EXPORT2 operator delete (void *, void *) U_NO_THROW
static void U_EXPORT2 operator delete (void *p) U_NO_THROW
static void U_EXPORT2 operator delete[] (void *p) U_NO_THROW
static void *U_EXPORT2 operator new (size_t, void *ptr) U_NO_THROW
static void *U_EXPORT2 operator new (size_t size) U_NO_THROW
static void *U_EXPORT2 operator new[] (size_t size) U_NO_THROW

Private Member Functions

void _init (int32_t initialCapacity, UErrorCode &status)
UVector32operator= (const UVector32 &)
 UVector32 (const UVector32 &)

Private Attributes

int32_t capacity
int32_t count
int32_t * elements
int32_t maxCapacity

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

Generated by  Doxygen 1.6.0   Back to index