RNBasics Package
Description:
The RNBasics package supports simple data types (RNScalar, RNInterval,
RNArray, RNQueue, RNHeap) and support several OS-dependent functions
(RNTime, RNMem, RNError).
The RNArray, RNQueue, and RNHeap classes are implemented as templates
that store collections of a specified data type (like STL classes).
The storage allocation for these containers is dynamic -- it expands
and contracts as entries are inserted and removed. Once a container
has been constructed, entries and the data stored in them can be
accessed, rearranged, or modified via member functions or iteration
macros. For example, an array of three strings could be constructed
and manipulated as follows:
// Construct the array
RNArray<char *> array; // Creates an empty array
array.Insert("String1"); // Insert the 1st string
array.Insert("String2"); // Insert the 2nd string
array.Insert("String3"); // Insert the 3rd string
// Access entries
char *data;
data = array.Head(); // data == "String1"
data = array.Tail(); // data == "String3"
data = array.Kth(0); // data == "String1"
data = array.Kth(1); // data == "String2"
data = array[1]; // data == "String2"
// Access all entries
for (int i = 0; i < array.NEntries(); i++) {
char *data = array[i]
printf("%s/n", data);
}
// Manipulate the array
array.Reverse(); // Reverse the order of entries
array.RemoveKth(1); // Remove the 2nd entry (first entry is at index 0)
array.InsertKth("String2", 1); // Re-insert string in 2nd entry
Other support functions include:
-
Base Classes:
-
Public Base Classes:
- None
-
Member Functions:
-
Constructor functions:
- RNVArray(void);
- RNVArray(const RNVArray& array);
- ~RNVArray(void);
-
-
Array property functions/operators:
- const RNBoolean IsEmpty(void) const;
- const int NAllocated(void) const;
- const int NEntries(void) const;
-
-
Entry property functions/operators:
- const int EntryIndex(const RNArrayEntry *entry) const;
- void *&EntryContents(RNArrayEntry *entry) const;
-
-
Data access functions/operators:
- void *Head(void) const;
- void *Tail(void) const;
- void *Kth(int k) const;
- void *operator[](int k) const;
-
-
Entry access functions/operators:
- RNArrayEntry *HeadEntry(void) const;
- RNArrayEntry *TailEntry(void) const;
- RNArrayEntry *KthEntry(int k) const;
- RNArrayEntry *PrevEntry(const RNArrayEntry *entry) const;
- RNArrayEntry *NextEntry(const RNArrayEntry *entry) const;
- RNArrayEntry *FindEntry(const void *data) const;
-
-
Insertion functions/operators:
- RNArrayEntry *InsertHead(void *data);
- RNArrayEntry *InsertTail(void *data);
- RNArrayEntry *InsertKth(void *data, int k);
- RNArrayEntry *InsertBefore(void *data, RNArrayEntry *entry);
- RNArrayEntry *InsertAfter(void *data, RNArrayEntry *entry);
- RNArrayEntry *Insert(void *data);
-
-
Removal functions/operators:
- void RemoveHead(void);
- void RemoveTail(void);
- void RemoveKth(int k);
- void RemoveEntry(RNArrayEntry *entry);
- void Remove(const void *data);
-
-
Manipulation functions/operators:
- void Empty(void);
- void Truncate(int length);
- void Shift(int delta);
- void Shift(int start, int length, int delta);
- void Reverse(void);
- void Reverse(int start, int length);
- void Append(const RNVArray& array);
- void Sort(int (*compare)(const void *data1, const void *data2));
- void BubbleSort(int (*compare)(void *data1, void *data2, void *appl), void *appl);
- void SwapEntries(RNArrayEntry *entry1, RNArrayEntry *entry2);
- void Swap(int i, int j);
- void Resize(int length);
- RNVArray& operator=(const RNVArray& array);
-
-
Debug function:
- RNBoolean IsValid(void) const;
-
-
Base Classes:
-
Public Base Classes:
- RNVArray
-
Member Functions:
-
Constructor functions:
-
Base Classes:
-
Public Base Classes:
- None
-
Member Functions:
-
Base Classes:
-
Public Base Classes:
- RNBase
-
Member Functions:
-
Constructor functions:
- RNFlags(void);
- RNFlags(unsigned long flags);
-
-
Type conversions:
- operator unsigned long(void) const;
-
-
Relationship functions/operators:
- int Intersects(const RNFlags flags) const;
- int Contains(const RNFlags flags) const;
- int operator[](const RNFlags flags) const;
-
-
Manipulation functions/operators:
- void Add(const RNFlags flags);
- void Remove(const RNFlags flags);
- void Intersect(const RNFlags flags);
-
-
Base Classes:
-
Public Base Classes:
- None
-
Member Functions:
-
Constructor functions:
- RNHeap(RNScalar (*value_callback)(PtrType, void *),
- PtrType **(*entry_callback)(PtrType, void *) = NULL,
- void *callback_data = NULL, int least_first = TRUE);
- RNHeap(PtrType base, RNScalar *value_ptr, PtrType **entry_ptr = NULL, int least_first = TRUE);
- RNHeap(int value_offset, int entry_offset = -1, int least_first = TRUE);
- ~RNHeap(void);
-
-
Data access functions:
- int IsEmpty(void) const;
- int NEntries(void) const;
- PtrType Kth(int k) const;
- PtrType operator[](int k) const;
- PtrType Peek(void) const;
-
-
Manipulation functions:
- void Empty(void);
- void Remove(PtrType data);
- void Update(PtrType data);
- void Push(PtrType data);
- PtrType Pop(void);
-
-
Debug functions:
- int IsValid(void);
-
-
Base Classes:
-
Public Base Classes:
- None
-
Member Functions:
-
Constructor/destructor functions:
- RNInterval();
- RNInterval(RNScalar a, RNScalar b);
- RNInterval(const RNInterval& interval);
-
-
Property functions:
- const RNScalar Min(void) const;
- const RNScalar Max(void) const;
- const RNScalar Mid(void) const;
- const RNScalar Diameter(void) const;
- const RNScalar Radius(void) const;
- const RNBoolean Contains(RNScalar a) const;
- const RNBoolean Contains(const RNInterval& iv) const;
- const RNBoolean Inside(const RNInterval& iv) const;
- const RNBoolean Intersects(const RNInterval& iv) const;
- const RNBoolean Abuts(const RNInterval& iv) const;
- const RNBoolean Disjoint(const RNInterval& iv) const;
- const RNBoolean IsEmpty(void) const;
-
-
Arithmetic operators:
- friend RNInterval operator +(const RNInterval &iv1, const RNInterval &interval2);
- friend RNInterval operator +(const RNInterval& iv, RNScalar a);
- friend RNInterval operator +(RNScalar a, const RNInterval& iv);
- friend RNInterval operator -(const RNInterval& iv1, const RNInterval& iv2);
- friend RNInterval operator -(const RNInterval& iv, RNScalar a);
- friend RNInterval operator -(RNScalar a, const RNInterval& iv);
- friend RNInterval operator -(const RNInterval& iv);
- friend RNInterval operator *(const RNInterval& iv1, const RNInterval& iv2);
- friend RNInterval operator *(const RNInterval& iv, RNScalar a);
- friend RNInterval operator *(RNScalar a, const RNInterval& iv);
- friend RNInterval operator /(const RNInterval& iv1, const RNInterval& iv2);
- friend RNInterval operator /(const RNInterval& iv, RNScalar a);
-
-
Relationship functions/operators:
- friend RNBoolean operator ==(const RNInterval& iv1, const RNInterval& iv2);
- friend RNBoolean operator !=(const RNInterval& iv1, const RNInterval& iv2);
- friend RNBoolean operator <(const RNInterval& iv1, const RNInterval& iv2);
- friend RNBoolean operator >(const RNInterval& iv1, const RNInterval& iv2);
- friend RNBoolean operator <=(const RNInterval& iv1, const RNInterval& iv2);
- friend RNBoolean operator >=(const RNInterval& iv1, const RNInterval& iv2);
- friend RNBoolean operator <(const RNInterval& iv, RNScalar a);
- friend RNBoolean operator >(const RNInterval& iv, RNScalar a);
- friend RNBoolean operator <=(const RNInterval& iv, RNScalar a);
- friend RNBoolean operator >=(const RNInterval& iv, RNScalar a);
- friend RNBoolean operator <(RNScalar a, const RNInterval& iv);
- friend RNBoolean operator >(RNScalar a, const RNInterval& iv);
- friend RNBoolean operator <=(RNScalar a, const RNInterval& iv);
- friend RNBoolean operator >=(RNScalar a, const RNInterval& iv);
-
- #if FALSE
-
ANSI math functions:
- friend RNInterval acos(const RNInterval& iv);
- friend RNInterval asin(const RNInterval& iv);
- friend RNInterval atan(const RNInterval& iv);
- friend RNInterval atan2(const RNInterval& iv1, const RNInterval& iv2);
- friend RNInterval ceil(const RNInterval& iv);
- friend RNInterval cos(const RNInterval& iv);
- friend RNInterval cosh(const RNInterval& iv);
- friend RNInterval exp(const RNInterval& iv);
- friend RNInterval fabs(const RNInterval& iv);
- friend RNInterval floor(const RNInterval& iv);
- friend RNInterval hypot(const RNInterval& iv1, const RNInterval& iv2);
- friend RNInterval log(const RNInterval& iv);
- friend RNInterval log10(const RNInterval& iv);
- friend RNInterval pow(const RNInterval& iv, RNScalar a);
- friend RNInterval sin(const RNInterval& iv);
- friend RNInterval sinh(const RNInterval& iv);
- friend RNInterval sqr(const RNInterval& iv);
- friend RNInterval sqrt(const RNInterval& iv);
- friend RNInterval tan(const RNInterval& iv);
- friend RNInterval tanh(const RNInterval& iv);
- #endif
-
-
Manipulation functions/operators:
- void Empty(void);
- void SetMin(RNScalar a);
- void SetMax(RNScalar b);
- void Union(RNScalar a);
- void Union(const RNInterval& iv);
- void Intersect(const RNInterval& iv);
- void Reset(RNScalar a, RNScalar b);
- void operator +=(const RNInterval& iv);
- void operator -=(const RNInterval& iv);
- void operator *=(const RNInterval& iv);
- void operator /=(const RNInterval& iv);
-
-
Base Classes:
-
Public Base Classes:
- None
-
Member Functions:
-
Constructor functions:
- RNVQueue(void);
- RNVQueue(const RNVQueue& queue);
-
-
Queue property functions/operators:
- const RNBoolean IsEmpty(void) const;
- const int NAllocated(void) const;
- const int NEntries(void) const;
-
-
Entry *property functions/operators:
- const int EntryIndex(const RNQueueEntry *entry) const;
- void *&EntryContents(RNQueueEntry *entry) const;
-
-
Data access functions/operators:
- void *Head(void) const;
- void *Tail(void) const;
- void *Kth(int k) const;
- void *operator[](int k) const;
-
-
Entry *access functions/operators:
- RNQueueEntry *HeadEntry(void) const;
- RNQueueEntry *TailEntry(void) const;
- RNQueueEntry *KthEntry(int k) const;
- RNQueueEntry *PrevEntry(const RNQueueEntry *entry) const;
- RNQueueEntry *NextEntry(const RNQueueEntry *entry) const;
- RNQueueEntry *FindEntry(const void *data) const;
-
-
Insertion/removal convenience functions:
- RNQueueEntry *Push(void *data);
- void *Pop(void);
- void *Peek(void);
-
-
Insertion functions/operators:
- RNQueueEntry *InsertHead(void *data);
- RNQueueEntry *InsertTail(void *data);
- RNQueueEntry *InsertKth(void *data, int k);
- RNQueueEntry *InsertBefore(void *data, RNQueueEntry *entry);
- RNQueueEntry *InsertAfter(void *data, RNQueueEntry *entry);
- RNQueueEntry *Insert(void *data);
-
-
Removal functions/operators:
- void RemoveHead(void);
- void RemoveTail(void);
- void RemoveKth(int k);
- void RemoveEntry(RNQueueEntry *entry);
- void Remove(const void *data);
-
-
Manipulation functions/operators:
- void Empty(void);
- void Shift(int delta);
- void Shift(int start, int length, int delta);
- void Reverse(void);
- void Reverse(int start, int length);
- void Resize(int length);
- RNVQueue& operator=(const RNVQueue& queue);
-
-
Debug functions/operators:
- RNBoolean IsValid(void) const;
-
-
Do not use these:
- RNQueueEntry *InternalInsert(void *data, int k);
- void InternalRemove(int k);
-
-
Base Classes:
-
Public Base Classes:
- RNVQueue
-
Member Functions:
-
Constructor functions:
-
Base Classes:
-
Public Base Classes:
- RNColor
-
Member Functions:
-
Constructor functions:
- RNRgb(void);
- RNRgb(const RNRgb& rgb);
- RNRgb(RNScalar red, RNScalar green, RNScalar blue);
- RNRgb(const RNScalar array[3]);
-
-
Property functions/operators:
- const RNScalar R(void) const;
- const RNScalar G(void) const;
- const RNScalar B(void) const;
- const RNScalar Coord(int i) const;
- const RNScalar operator[](int i) const;
- const RNScalar *Coords(void) const;
- const RNScalar Luminance(void) const;
- const int IsBlack(void) const;
- const int IsWhite(void) const;
- const int operator==(const RNRgb& rgb) const;
- const int operator!=(const RNRgb& rgb) const;
-
-
Manipulation functions/operations:
- void SetRed(RNScalar red);
- void SetGreen(RNScalar green);
- void SetBlue(RNScalar blue);
- void Reset(RNScalar red, RNScalar green, RNScalar blue);
-
-
Assignment operators:
- RNRgb& operator=(const RNRgb& rgb);
- RNRgb& operator+=(const RNRgb& rgb);
- RNRgb& operator-=(const RNRgb& rgb);
- RNRgb& operator*=(const RNRgb& rgb);
- RNRgb& operator*=(RNScalar a);
- RNRgb& operator/=(RNScalar a);
-
-
Arithmetic operations:
- friend RNRgb operator+(const RNRgb& rgb1, const RNRgb& rgb2);
- friend RNRgb operator-(const RNRgb& rgb1, const RNRgb& rgb2);
- friend RNRgb operator*(const RNRgb& rgb1, const RNRgb& rgb2);
- friend RNRgb operator*(const RNRgb& rgb, RNScalar a);
- friend RNRgb operator*(RNScalar a, const RNRgb& rgb);
- friend RNRgb operator/(const RNRgb& rgb, RNScalar a);
-
-
Undocumented functions/operators:
- RNScalar& operator[](int i);
-
-
Base Classes:
-
Public Base Classes:
- RNBase
-
Member Functions:
-
Constructor functions:
- RNTime(void);
- RNTime(const RNTime& tm);
-
-
Relationship functions/operators:
- RNScalar Elapsed(const RNTime& tm) const;
- RNScalar Elapsed(void) const;
-
-
Arithmetic operators:
- RNScalar operator-(const RNTime& tm) const;
-
-
Manipulation functions/operators:
- void Read(void);
-
-
Base Classes:
-
Public Base Classes:
- None
-
Member Functions:
-
Constructor functions:
- RNClassType(RNClassID id, const char *name);
- RNClassType(const char *name);
- ~RNClassType(void);
-
-
Property functions:
- const RNClassID ID(void) const;
- const char *Name(void) const;
-
-
Base Classes:
-
Public Base Classes:
- None
-
Member Functions:
Click this to go back to list of GAPS packages.