#include <opennurbs_array.h>

Public Member Functions

 ON_SimpleArray () ON_NOEXCEPT
 construction //////////////////////////////////////////////////////// More...
 
 ON_SimpleArray (const ON_SimpleArray< T > &)
 Copy constructor. More...
 
 ON_SimpleArray (size_t)
 
virtual ~ON_SimpleArray ()
 
void Append (const T &)
 
void Append (int, const T *)
 
T & AppendNew ()
 array operations //////////////////////////////////////////////////// More...
 
T * Array ()
 
const T * Array () const
 
T * At (int)
 At(index) returns nullptr if index < 0 or index >= count. More...
 
T * At (unsigned int)
 
T * At (ON__INT64)
 
T * At (ON__UINT64)
 
const T * At (int) const
 
const T * At (unsigned int) const
 
const T * At (ON__INT64) const
 
const T * At (ON__UINT64) const
 
int BinarySearch (const T *, int(*)(const T *, const T *)) const
 
int BinarySearch (const T *, int(*)(const T *, const T *), int) const
 
int Capacity () const
 
int Count () const
 query /////////////////////////////////////////////////////////////// More...
 
ON__UINT32 DataCRC (ON__UINT32 current_remainder) const
 
void Destroy ()
 
void EmergencyDestroy (void)
 emergency bailout /////////////////////////////////////////////////// More...
 
void Empty ()
 
T * First ()
 
const T * First () const
 
bool HeapSort (int(*)(const T *, const T *))
 
void Insert (int, const T &)
 
T * KeepArray ()
 Expert user tool to take charge of the memory used by the dyanmic array. More...
 
T * Last ()
 
const T * Last () const
 
void MemSet (unsigned char)
 
int NewCapacity () const
 
 operator const T * () const
 
 operator T* ()
 
ON_SimpleArray< T > & operator= (const ON_SimpleArray< T > &)
 
T & operator[] (int)
 
T & operator[] (unsigned int)
 
T & operator[] (ON__INT64)
 
T & operator[] (ON__UINT64)
 
const T & operator[] (int) const
 
const T & operator[] (unsigned int) const
 
const T & operator[] (ON__INT64) const
 
const T & operator[] (ON__UINT64) const
 
bool Permute (const int *)
 
bool QuickSort (int(*)(const T *, const T *))
 
virtual T * Realloc (T *, int)
 low level memory managment ////////////////////////////////////////// More...
 
void Remove ()
 
virtual void Remove (int)
 
T * Reserve (size_t)
 memory managment //////////////////////////////////////////////////// More...
 
void Reverse ()
 
int Search (const T &) const
 
int Search (const T *, int(*)(const T *, const T *)) const
 
void SetArray (T *)
 Do not use this version of SetArray(). Use the one that takes a pointer, count and capacity. More...
 
void SetArray (T *, int, int)
 Expert user tool to set the memory used by the dyanmic array. More...
 
T * SetCapacity (size_t)
 
void SetCount (int)
 low level memory managment ////////////////////////////////////////// More...
 
void Shrink ()
 
unsigned int SizeOfArray () const
 
unsigned int SizeOfElement () const
 
bool Sort (ON::sort_algorithm sort_algorithm, int *, int(*)(const T *, const T *)) const
 Sort() fills in the index[] array so that array[index[i]] <= array[index[i+1]]. The array is not modified. More...
 
bool Sort (ON::sort_algorithm sort_algorithm, int *, int(*)(const T *, const T *, void *), void *) const
 Sort() fills in the index[] array so that array[index[i]] <= array[index[i+1]]. The array is not modified. More...
 
void Swap (int, int)
 
unsigned int UnsignedCount () const
 
void Zero ()
 

Protected Member Functions

void Move (int, int, int)
 implimentation ////////////////////////////////////////////////////// More...
 

Protected Attributes

T * m_a
 
int m_capacity
 
int m_count
 

Constructor & Destructor Documentation

◆ ON_SimpleArray() [1/3]

template<class T >
ON_SimpleArray< T >::ON_SimpleArray ( )

construction ////////////////////////////////////////////////////////

◆ ~ON_SimpleArray()

template<class T >
ON_SimpleArray< T >::~ON_SimpleArray ( )
virtual

◆ ON_SimpleArray() [2/3]

template<class T>
ON_SimpleArray< T >::ON_SimpleArray ( const ON_SimpleArray< T > &  src)

Copy constructor.

◆ ON_SimpleArray() [3/3]

template<class T>
ON_SimpleArray< T >::ON_SimpleArray ( size_t  c)

Member Function Documentation

◆ Append() [1/2]

template<class T>
void ON_SimpleArray< T >::Append ( const T &  x)

◆ Append() [2/2]

template<class T>
void ON_SimpleArray< T >::Append ( int  count,
const T *  p 
)

◆ AppendNew()

template<class T >
T & ON_SimpleArray< T >::AppendNew ( )

array operations ////////////////////////////////////////////////////

◆ Array() [1/2]

template<class T >
T * ON_SimpleArray< T >::Array ( )

◆ Array() [2/2]

template<class T >
const T * ON_SimpleArray< T >::Array ( ) const

◆ At() [1/8]

template<class T >
T * ON_SimpleArray< T >::At ( int  i)

At(index) returns nullptr if index < 0 or index >= count.

◆ At() [2/8]

template<class T >
T * ON_SimpleArray< T >::At ( unsigned int  i)

◆ At() [3/8]

template<class T >
T * ON_SimpleArray< T >::At ( ON__INT64  i)

◆ At() [4/8]

template<class T >
T * ON_SimpleArray< T >::At ( ON__UINT64  i)

◆ At() [5/8]

template<class T >
const T * ON_SimpleArray< T >::At ( int  i) const

◆ At() [6/8]

template<class T >
const T * ON_SimpleArray< T >::At ( unsigned int  i) const

◆ At() [7/8]

template<class T >
const T * ON_SimpleArray< T >::At ( ON__INT64  i) const

◆ At() [8/8]

template<class T >
const T * ON_SimpleArray< T >::At ( ON__UINT64  i) const

◆ BinarySearch() [1/2]

template<class T>
int ON_SimpleArray< T >::BinarySearch ( const T *  key,
int(*)(const T *, const T *)  compar 
) const

This worked on a wide range of 32 bit compilers.

Convert "found" pointer to array index.

"key" not found

◆ BinarySearch() [2/2]

template<class T>
int ON_SimpleArray< T >::BinarySearch ( const T *  key,
int(*)(const T *, const T *)  compar,
int  count 
) const

This worked on a wide range of 32 bit compilers.

Convert "found" pointer to array index.

"key" not found

◆ Capacity()

template<class T >
int ON_SimpleArray< T >::Capacity ( ) const

◆ Count()

template<class T >
int ON_SimpleArray< T >::Count ( ) const

query ///////////////////////////////////////////////////////////////

◆ DataCRC()

template<class T >
ON__UINT32 ON_SimpleArray< T >::DataCRC ( ON__UINT32  current_remainder) const

◆ Destroy()

template<class T >
void ON_SimpleArray< T >::Destroy ( )

◆ EmergencyDestroy()

template<class T >
void ON_SimpleArray< T >::EmergencyDestroy ( void  )

emergency bailout ///////////////////////////////////////////////////

emergency destroy ///////////////////////////////////////////////////

◆ Empty()

template<class T >
void ON_SimpleArray< T >::Empty ( )

◆ First() [1/2]

template<class T >
T * ON_SimpleArray< T >::First ( )

◆ First() [2/2]

template<class T >
const T * ON_SimpleArray< T >::First ( ) const

◆ HeapSort()

template<class T>
bool ON_SimpleArray< T >::HeapSort ( int(*)(const T *, const T *)  compar)

◆ Insert()

template<class T>
void ON_SimpleArray< T >::Insert ( int  i,
const T &  x 
)

◆ KeepArray()

template<class T >
T * ON_SimpleArray< T >::KeepArray ( )

Expert user tool to take charge of the memory used by the dyanmic array.

Returns
A pointer to the array and zeros out this class. The returned pointer is on the heap and must be deallocated by calling onfree().

◆ Last() [1/2]

template<class T >
T * ON_SimpleArray< T >::Last ( )

◆ Last() [2/2]

template<class T >
const T * ON_SimpleArray< T >::Last ( ) const

◆ MemSet()

template<class T >
void ON_SimpleArray< T >::MemSet ( unsigned char  value)

◆ Move()

template<class T >
void ON_SimpleArray< T >::Move ( int  dest_i,
int  src_i,
int  ele_cnt 
)
protected

implimentation //////////////////////////////////////////////////////

array operations ////////////////////////////////////////////////////

◆ NewCapacity()

template<class T >
int ON_SimpleArray< T >::NewCapacity ( ) const

cap_size = 128 MB on 32-bit os, 256 MB on 64 bit os

◆ operator const T *()

template<class T >
ON_SimpleArray< T >::operator const T * ( ) const

◆ operator T*()

template<class T >
ON_SimpleArray< T >::operator T* ( )

◆ operator=()

template<class T>
ON_SimpleArray< T > & ON_SimpleArray< T >::operator= ( const ON_SimpleArray< T > &  src)

◆ operator[]() [1/8]

template<class T >
T & ON_SimpleArray< T >::operator[] ( int  i)

◆ operator[]() [2/8]

template<class T >
T & ON_SimpleArray< T >::operator[] ( unsigned int  i)

◆ operator[]() [3/8]

template<class T >
T & ON_SimpleArray< T >::operator[] ( ON__INT64  i)

◆ operator[]() [4/8]

template<class T >
T & ON_SimpleArray< T >::operator[] ( ON__UINT64  i)

◆ operator[]() [5/8]

template<class T >
const T & ON_SimpleArray< T >::operator[] ( int  i) const

◆ operator[]() [6/8]

template<class T >
const T & ON_SimpleArray< T >::operator[] ( unsigned int  i) const

◆ operator[]() [7/8]

template<class T >
const T & ON_SimpleArray< T >::operator[] ( ON__INT64  i) const

◆ operator[]() [8/8]

template<class T >
const T & ON_SimpleArray< T >::operator[] ( ON__UINT64  i) const

◆ Permute()

template<class T >
bool ON_SimpleArray< T >::Permute ( const int *  index)

◆ QuickSort()

template<class T>
bool ON_SimpleArray< T >::QuickSort ( int(*)(const T *, const T *)  compar)

◆ Realloc()

template<class T>
T * ON_SimpleArray< T >::Realloc ( T *  ptr,
int  capacity 
)
virtual

low level memory managment //////////////////////////////////////////

Class ON_SimpleArray<>

construction ////////////////////////////////////////////////////////

◆ Remove() [1/2]

template<class T >
void ON_SimpleArray< T >::Remove ( )

◆ Remove() [2/2]

template<class T >
void ON_SimpleArray< T >::Remove ( int  i)
virtual

◆ Reserve()

template<class T >
T * ON_SimpleArray< T >::Reserve ( size_t  newcap)

memory managment ////////////////////////////////////////////////////

◆ Reverse()

template<class T >
void ON_SimpleArray< T >::Reverse ( )

◆ Search() [1/2]

template<class T>
int ON_SimpleArray< T >::Search ( const T &  key) const

◆ Search() [2/2]

template<class T>
int ON_SimpleArray< T >::Search ( const T *  key,
int(*)(const T *, const T *)  compar 
) const

◆ SetArray() [1/2]

template<class T>
void ON_SimpleArray< T >::SetArray ( T *  p)

Do not use this version of SetArray(). Use the one that takes a pointer, count and capacity.

◆ SetArray() [2/2]

template<class T>
void ON_SimpleArray< T >::SetArray ( T *  p,
int  count,
int  capacity 
)

Expert user tool to set the memory used by the dyanmic array.

TODODOC: T* pointer - [in] TODODOC: int count [in] TODODOC: int capacity - [in] TODODOC: m_a is set to pointer, m_count is set to count, and m_capacity TODODOC: is set to capacity. It is critical that the pointer be one TODODOC: returned by onmalloc(sz), where sz >= capacity*sizeof(T[0]).

◆ SetCapacity()

template<class T >
T * ON_SimpleArray< T >::SetCapacity ( size_t  new_capacity)

sets capacity to input value

NOTE: Realloc() does an allocation if the first argument is nullptr.

zero new memory

out of memory

◆ SetCount()

template<class T >
void ON_SimpleArray< T >::SetCount ( int  count)

low level memory managment //////////////////////////////////////////

◆ Shrink()

template<class T >
void ON_SimpleArray< T >::Shrink ( )

◆ SizeOfArray()

template<class T >
unsigned int ON_SimpleArray< T >::SizeOfArray ( ) const

◆ SizeOfElement()

template<class T >
unsigned int ON_SimpleArray< T >::SizeOfElement ( ) const

◆ Sort() [1/2]

template<class T>
bool ON_SimpleArray< T >::Sort ( ON::sort_algorithm  sort_algorithm,
int *  index,
int(*)(const T *, const T *)  compar 
) const

Sort() fills in the index[] array so that array[index[i]] <= array[index[i+1]]. The array is not modified.

Parameters
sort_algorithm[in] ON::sort_algorithm::quick_sort (best in general) or ON::sort_algorithm::heap_sort Use ON::sort_algorithm::heap_sort only if you have done extensive testing with optimized release builds and are confident heap sort is significantly faster.
index[out] an array of length Count() that is returned with some permutation of (0,1,...,Count()-1).
compare[in] compare function compare(a,b,p) should return <0 if a<b, 0, if a==b, and >0 if a>b.
Returns
true if successful

◆ Sort() [2/2]

template<class T>
bool ON_SimpleArray< T >::Sort ( ON::sort_algorithm  sort_algorithm,
int *  index,
int(*)(const T *, const T *, void *)  compar,
void *  p 
) const

Sort() fills in the index[] array so that array[index[i]] <= array[index[i+1]]. The array is not modified.

Parameters
sort_algorithm[in] ON::sort_algorithm::quick_sort (best in general) or ON::sort_algorithm::heap_sort Use ON::sort_algorithm::heap_sort only if you have done extensive testing with optimized release builds and are confident heap sort is significantly faster.
index[out] an array of length Count() that is returned with some permutation of (0,1,...,Count()-1).
compare[in] compare function compare(a,b,p) should return <0 if a<b, 0, if a==b, and >0 if a>b.
p[in] pointer passed as third argument to compare.
Returns
true if successful

◆ Swap()

template<class T >
void ON_SimpleArray< T >::Swap ( int  i,
int  j 
)

◆ UnsignedCount()

template<class T >
unsigned int ON_SimpleArray< T >::UnsignedCount ( ) const

◆ Zero()

template<class T >
void ON_SimpleArray< T >::Zero ( )

Member Data Documentation

◆ m_a

template<class T>
T* ON_SimpleArray< T >::m_a
protected

◆ m_capacity

template<class T>
int ON_SimpleArray< T >::m_capacity
protected

◆ m_count

template<class T>
int ON_SimpleArray< T >::m_count
protected