HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_Array< T > Class Template Reference

#include <BV_KDOPTree.h>

+ Inheritance diagram for UT_Array< T >:

Classes

class  base_iterator
 
class  IndexedCompare
 Comparator class for stableSortIndices. More...
 

Public Types

typedef T value_type
 
typedef int(* Comparator )(const T *, const T *)
 
typedef base_iterator< T, true > iterator
 
typedef base_iterator< const T,
true > 
const_iterator
 
typedef base_iterator< T, false > reverse_iterator
 
typedef base_iterator< const T,
false > 
const_reverse_iterator
 
typedef const_iterator traverser
 

Public Member Functions

 UT_Array (const UT_Array< T > &a)
 
 UT_Array (UT_Array< T > &&a) SYS_NOEXCEPT
 Move constructor. Steals the working data from the original. More...
 
 UT_Array (exint capacity, exint size)
 Construct based on given capacity and size. More...
 
 UT_Array (exint capacity=0)
 Construct based on given capacity with a size of 0. More...
 
 UT_Array (std::initializer_list< T > init)
 Construct with the contents of an initializer list. More...
 
 ~UT_Array ()
 
void swap (UT_Array< T > &other)
 
exint append (void)
 
exint append (const T &t)
 
exint append (T &&t)
 
exint append (const T &t, bool check_dup)
 
void append (const T *pt, exint count)
 
void appendMultiple (const T &t, exint count)
 
exint insert (exint index)
 
exint insert (const T &t, exint i)
 
exint insert (T &&t, exint i)
 
template<typename... S>
exint emplace_back (S &&...s)
 
exint uniqueSortedInsert (const T &t, Comparator compare)
 
template<typename ComparatorBool >
exint uniqueSortedInsert (const T &t, ComparatorBool is_less)
 
exint uniqueSortedFind (const T &item, Comparator compare) const
 
template<typename ComparatorBool >
exint uniqueSortedFind (const T &item, ComparatorBool is_less) const
 
template<typename ComparatorBool >
void merge (const UT_Array< T > &other, int direction, bool allow_dups, ComparatorBool is_less)
 
bool hasSortedSubset (const UT_Array< T > &other, Comparator compare) const
 
void sortedUnion (const UT_Array< T > &other, Comparator compare)
 
void sortedUnion (const UT_Array< T > &other, UT_Array< T > &result, Comparator compare) const
 
void sortedIntersection (const UT_Array< T > &other, Comparator compare)
 
void sortedIntersection (const UT_Array< T > &other, UT_Array< T > &result, Comparator compare) const
 
void sortedSetDifference (const UT_Array< T > &other, Comparator compare)
 
void sortedSetDifference (const UT_Array< T > &other, UT_Array< T > &result, Comparator compare) const
 
exint heapPush (const T &t, Comparator compare)
 
T heapPop (Comparator compare)
 
const TheapMax () const
 
exint concat (const UT_Array< T > &a)
 Takes another T array and concatenate it onto my end. More...
 
exint multipleInsert (exint index, exint count)
 Insert an element "count" times at the given index. Return the index. More...
 
exint insertAt (const T &t, exint index)
 
bool isValidIndex (exint index) const
 Return true if given index is valid. More...
 
exint findAndRemove (const T &t)
 
exint removeIndex (exint index)
 
SYS_FORCE_INLINE void removeLast ()
 
void removeRange (exint begin_i, exint end_i)
 Remove the range [begin_i,end_i) of elements from the array. More...
 
void extractRange (exint begin_i, exint end_i, UT_Array< T > &dest)
 
template<typename IsEqual >
exint removeIf (IsEqual is_equal)
 
template<typename IsEqual >
void collapseIf (IsEqual is_equal)
 Remove all matching elements. Also sets the capacity of the array. More...
 
void move (exint srcIdx, exint destIdx, exint howMany)
 
void cycle (exint howMany)
 Cyclically shifts the entire array by howMany. More...
 
void constant (const T &v)
 Quickly set the array to a single value. More...
 
void zero ()
 Zeros the array if a POD type, else trivial constructs if a class type. More...
 
exint find (const T &t, exint s=0) const
 
exint find (const T &t, Comparator compare) const
 
void reverse ()
 Reverses the array by swapping elements in mirrored locations. More...
 
exint index (const T &t) const
 
exint safeIndex (const T &t) const
 
void sort (Comparator compare)
 
template<typename ComparatorBool >
void stdsort (ComparatorBool is_less)
 Sort using std::sort. The ComparatorBool uses the less-than semantics. More...
 
template<typename ComparatorBool >
void stableSort (ComparatorBool is_less)
 
template<typename I , typename ComparatorBool >
void stableSortIndices (UT_Array< I > &indices, ComparatorBool is_less) const
 
template<typename I , typename ComparatorBool >
void stableArgSort (UT_Array< I > &indices, ComparatorBool is_less) const
 
template<typename K , typename ComparatorBool >
void stableSortByKey (const UT_Array< K > &keys, ComparatorBool is_less)
 
exint sortedRemoveDuplicates ()
 
template<typename CompareEqual >
exint sortedRemoveDuplicatesIf (CompareEqual compare_equal)
 
template<typename ComparatorBool >
void sortAndRemoveDuplicates (ComparatorBool is_less)
 
template<typename ComparatorBool >
T selectNthLargest (exint idx, ComparatorBool is_less)
 
void setCapacity (exint newcapacity)
 
void setCapacityIfNeeded (exint mincapacity)
 
void bumpCapacity (exint mincapacity)
 
void bumpSize (exint newsize)
 
void bumpEntries (exint newsize)
 
exint capacity () const
 
exint size () const
 
exint entries () const
 Alias of size(). size() is preferred. More...
 
bool isEmpty () const
 Returns true iff there are no occupied elements in the array. More...
 
int64 getMemoryUsage (bool inclusive=false) const
 
void setSize (exint newsize)
 
void entries (exint newsize)
 Alias of setSize(). setSize() is preferred. More...
 
void setSizeNoInit (exint newsize)
 
void truncate (exint maxsize)
 Decreases, but never expands, to the given maxsize. More...
 
void clear ()
 Resets list to an empty list. More...
 
UT_Array< T > & operator= (const UT_Array< T > &a)
 
UT_Array< T > & operator= (std::initializer_list< T > ilist)
 Replace the contents with those from the initializer_list ilist. More...
 
UT_Array< T > & operator= (UT_Array< T > &&a)
 Move the contents of array a to this array. More...
 
bool operator== (const UT_Array< T > &a) const
 
bool operator!= (const UT_Array< T > &a) const
 
int isEqual (const UT_Array< T > &a, Comparator compare) const
 
Toperator() (exint i)
 
const Toperator() (exint i) const
 
Toperator[] (exint i)
 
const Toperator[] (exint i) const
 
TforcedRef (exint i)
 
T forcedGet (exint i) const
 
Tlast ()
 
const Tlast () const
 
exint apply (int(*applyFct)(T &t, void *d), void *d)
 
template<typename BinaryOp >
T accumulate (const T &init_value, BinaryOp add) const
 
TgetArray () const
 
const TgetRawArray () const
 
Tarray ()
 
const Tarray () const
 
Tdata ()
 
const Tdata () const
 
TaliasArray (T *newdata)
 
iterator begin ()
 
iterator end ()
 End iterator. More...
 
const_iterator begin () const
 
const_iterator end () const
 End const iterator. Consider using it.atEnd() instead. More...
 
reverse_iterator rbegin ()
 Begin iterating over the array in reverse. More...
 
reverse_iterator rend ()
 End reverse iterator. More...
 
const_reverse_iterator rbegin () const
 Begin iterating over the array in reverse. More...
 
const_reverse_iterator rend () const
 End reverse iterator. Consider using it.atEnd() instead. More...
 
UT_IteratorRange< iteratorrange ()
 
UT_IteratorRange< const_iteratorrange () const
 
UT_IteratorRange
< reverse_iterator
rrange ()
 
UT_IteratorRange
< const_reverse_iterator
rrange () const
 
void removeItem (const reverse_iterator &it)
 Remove item specified by the reverse_iterator. More...
 
void unsafeShareData (UT_Array< T > &src)
 
void unsafeShareData (T *src, exint srcsize)
 
void unsafeShareData (T *src, exint size, exint capacity)
 
void unsafeClearData ()
 
bool isHeapBuffer () const
 Returns true if the data used by the array was allocated on the heap. More...
 
bool isHeapBuffer (T *data) const
 
exint sortedInsert (const T &t, Comparator compare)
 
template<typename ComparatorBool >
exint sortedInsert (const T &t, ComparatorBool is_less)
 

Protected Member Functions

template<typename S >
exint appendImpl (S &&s)
 
template<typename S >
exint insertImpl (S &&s, exint index)
 Similar to appendImpl() but for insertion. More...
 
template<typename First , typename... Rest>
void validateEmplaceArgs (First &&first, Rest &&...rest) const
 
void validateEmplaceArgs () const
 Base case for validateEmplaceArgs(). More...
 

Static Protected Member Functions

static constexpr
SYS_FORCE_INLINE bool 
isPOD ()
 
template<typename... S>
static void construct (T &dst, S &&...s)
 
static void copyConstruct (T &dst, const T &src)
 
static void copyConstructRange (T *dst, const T *src, exint n)
 
static void trivialConstruct (T &dst)
 Element Constructor. More...
 
static void trivialConstructRange (T *dst, exint n)
 
static SYS_FORCE_INLINE void trivialDestruct (T &dst)
 Element Destructor. More...
 
static void trivialDestructRange (T *dst, exint n)
 

Friends

template<typename OS , typename S >
OS & operator<< (OS &os, const UT_Array< S > &d)
 
void swap (UT_Array< T > &a, UT_Array< T > &b)
 

Detailed Description

Member Typedef Documentation

template<class T>
typedef int(* UT_Array< T >::Comparator)(const T *, const T *)

Definition at line 45 of file UT_Array.h.

template<class T>
typedef base_iterator<const T, true> UT_Array< T >::const_iterator

Definition at line 772 of file UT_Array.h.

template<class T>
typedef base_iterator<const T, false> UT_Array< T >::const_reverse_iterator

Definition at line 774 of file UT_Array.h.

template<class T>
typedef base_iterator<T, true> UT_Array< T >::iterator

Definition at line 771 of file UT_Array.h.

template<class T>
typedef base_iterator<T, false> UT_Array< T >::reverse_iterator

Definition at line 773 of file UT_Array.h.

template<class T>
typedef const_iterator UT_Array< T >::traverser

Definition at line 775 of file UT_Array.h.

template<class T>
typedef T UT_Array< T >::value_type

Definition at line 43 of file UT_Array.h.

Constructor & Destructor Documentation

template<typename T>
UT_Array< T >::UT_Array ( const UT_Array< T > &  a)
explicit

Copy constructor. It duplicates the data. It's marked explicit so that it's not accidentally passed by value. You can always pass by reference and then copy it, if needed. If you have a line like: UT_Array<int> a = otherarray; and it really does need to copy instead of referencing, you can rewrite it as: UT_Array<int> a(otherarray);

Definition at line 38 of file UT_ArrayImpl.h.

template<typename T>
UT_Array< T >::UT_Array ( UT_Array< T > &&  a)

Move constructor. Steals the working data from the original.

Definition at line 68 of file UT_ArrayImpl.h.

template<class T>
UT_Array< T >::UT_Array ( exint  capacity,
exint  size 
)
inline

Construct based on given capacity and size.

Definition at line 61 of file UT_Array.h.

template<class T>
UT_Array< T >::UT_Array ( exint  capacity = 0)
inlineexplicit

Construct based on given capacity with a size of 0.

Definition at line 72 of file UT_Array.h.

template<typename T>
UT_Array< T >::UT_Array ( std::initializer_list< T init)
explicit

Construct with the contents of an initializer list.

Definition at line 53 of file UT_ArrayImpl.h.

template<typename T >
UT_Array< T >::~UT_Array ( )

Definition at line 88 of file UT_ArrayImpl.h.

Member Function Documentation

template<typename T>
template<typename BinaryOp >
T UT_Array< T >::accumulate ( const T init_value,
BinaryOp  add 
) const

Definition at line 1216 of file UT_ArrayImpl.h.

template<class T>
T* UT_Array< T >::aliasArray ( T newdata)
inline

This method allows you to swap in a new raw T array, which must be the same size as myCapacity. Use caution with this method.

Definition at line 622 of file UT_Array.h.

template<class T>
exint UT_Array< T >::append ( void  )
inline

Append an element to the current elements and return its index in the array, or insert the element at a specified position; if necessary, insert() grows the array to accommodate the element. The insert methods use the assignment operator '=' to place the element into the right spot; be aware that '=' works differently on objects and pointers. The test for duplicates uses the logical equal operator '=='; as with '=', the behaviour of the equality operator on pointers versus objects is not the same. Use the subscript operators instead of insert() if you are appending to the array, or if you don't mind overwriting the element already inserted at the given index.

Examples:
euclid/EUC_Expression.C, OPUI/OPUI_HighlightBadge.C, and OPUI/OPUI_MemUsageTextBadge.C.

Definition at line 95 of file UT_Array.h.

template<class T>
exint UT_Array< T >::append ( const T t)
inline

Definition at line 96 of file UT_Array.h.

template<class T>
exint UT_Array< T >::append ( T &&  t)
inline

Definition at line 97 of file UT_Array.h.

template<class T>
exint UT_Array< T >::append ( const T t,
bool  check_dup 
)
inline

Definition at line 98 of file UT_Array.h.

template<typename T>
void UT_Array< T >::append ( const T pt,
exint  count 
)

Definition at line 186 of file UT_ArrayImpl.h.

template<typename T >
template<typename S >
exint UT_Array< T >::appendImpl ( S &&  s)
protected

Implements both append(const T &) and append(T &&) via perfect forwarding. Unlike the variadic emplace_back(), its argument may be a reference to another element in the array.

Definition at line 148 of file UT_ArrayImpl.h.

template<typename T>
void UT_Array< T >::appendMultiple ( const T t,
exint  count 
)

Definition at line 195 of file UT_ArrayImpl.h.

template<typename T>
exint UT_Array< T >::apply ( int(*)(T &t, void *d)  applyFct,
void d 
)

Apply a user-defined function to each element of the array as int as the function returns zero. If applyFct returns 1, apply() stops traversing the list and returns the current index; otherwise, apply() returns the size.

Definition at line 942 of file UT_ArrayImpl.h.

template<class T>
T* UT_Array< T >::array ( )
inline

Definition at line 614 of file UT_Array.h.

template<class T>
const T* UT_Array< T >::array ( ) const
inline

Definition at line 615 of file UT_Array.h.

template<class T>
iterator UT_Array< T >::begin ( void  )
inline

Begin iterating over the array. The contents of the array may be modified during the traversal.

Definition at line 779 of file UT_Array.h.

template<class T>
const_iterator UT_Array< T >::begin ( void  ) const
inline

Begin iterating over the array. The array may not be modified during the traversal.

Definition at line 792 of file UT_Array.h.

template<class T>
void UT_Array< T >::bumpCapacity ( exint  mincapacity)
inline

If the capacity is smaller than mincapacity, expand the array to at least mincapacity and to at least a constant factor of the array's previous capacity, to avoid having a linear number of reallocations in a linear number of calls to bumpCapacity.

Definition at line 417 of file UT_Array.h.

template<class T>
void UT_Array< T >::bumpEntries ( exint  newsize)
inline

NOTE: bumpEntries() will be deprecated in favour of bumpSize() in a future version.

Definition at line 441 of file UT_Array.h.

template<class T>
void UT_Array< T >::bumpSize ( exint  newsize)
inline

First bumpCapacity to ensure that there's space for newsize, expanding either not at all or by at least a constant factor of the array's previous capacity, then set the size to newsize.

Definition at line 434 of file UT_Array.h.

template<class T>
exint UT_Array< T >::capacity ( ) const
inline

Query the capacity, i.e. the allocated length of the array. NOTE: capacity() >= size().

Definition at line 448 of file UT_Array.h.

template<class T>
void UT_Array< T >::clear ( void  )
inline

Resets list to an empty list.

Definition at line 513 of file UT_Array.h.

template<class T>
template<typename IsEqual >
void UT_Array< T >::collapseIf ( IsEqual  is_equal)
inline

Remove all matching elements. Also sets the capacity of the array.

Definition at line 248 of file UT_Array.h.

template<typename T>
exint UT_Array< T >::concat ( const UT_Array< T > &  a)

Takes another T array and concatenate it onto my end.

Definition at line 414 of file UT_ArrayImpl.h.

template<typename T>
void UT_Array< T >::constant ( const T v)

Quickly set the array to a single value.

Definition at line 668 of file UT_ArrayImpl.h.

template<class T>
template<typename... S>
static void UT_Array< T >::construct ( T dst,
S &&...  s 
)
inlinestaticprotected

Definition at line 923 of file UT_Array.h.

template<class T>
static void UT_Array< T >::copyConstruct ( T dst,
const T src 
)
inlinestaticprotected

Definition at line 929 of file UT_Array.h.

template<class T>
static void UT_Array< T >::copyConstructRange ( T dst,
const T src,
exint  n 
)
inlinestaticprotected

Definition at line 936 of file UT_Array.h.

template<typename T >
void UT_Array< T >::cycle ( exint  howMany)

Cyclically shifts the entire array by howMany.

Definition at line 646 of file UT_ArrayImpl.h.

template<class T>
T* UT_Array< T >::data ( )
inline

Definition at line 617 of file UT_Array.h.

template<class T>
const T* UT_Array< T >::data ( ) const
inline

Definition at line 618 of file UT_Array.h.

template<typename T >
template<typename... S>
exint UT_Array< T >::emplace_back ( S &&...  s)

Adds a new element to the array (resizing if necessary) and forwards the given arguments to T's constructor. NOTE: Unlike append(), the arguments cannot reference any existing elements in the array. Checking for and handling such cases would remove most of the performance gain versus append(T(...)). Debug builds will assert that the arguments are valid.

Definition at line 171 of file UT_ArrayImpl.h.

template<class T>
iterator UT_Array< T >::end ( void  )
inline

End iterator.

Definition at line 784 of file UT_Array.h.

template<class T>
const_iterator UT_Array< T >::end ( void  ) const
inline

End const iterator. Consider using it.atEnd() instead.

Definition at line 797 of file UT_Array.h.

template<class T>
exint UT_Array< T >::entries ( void  ) const
inline

Alias of size(). size() is preferred.

Definition at line 453 of file UT_Array.h.

template<class T>
void UT_Array< T >::entries ( exint  newsize)
inline

Alias of setSize(). setSize() is preferred.

Definition at line 483 of file UT_Array.h.

template<typename T>
void UT_Array< T >::extractRange ( exint  begin_i,
exint  end_i,
UT_Array< T > &  dest 
)

Remove the range [begin_i, end_i) of elements from this array and place them in the dest array, shrinking/growing the dest array as necessary.

Definition at line 537 of file UT_ArrayImpl.h.

template<typename T>
exint UT_Array< T >::find ( const T t,
exint  s = 0 
) const

Search for t in one of two ways: linearly using the '==' operator, or binary using the function specified in the parameter list respectively. find() returns the index of the matching element or (exint)-1. Parameter s indicates the index the search should start at.

Definition at line 693 of file UT_ArrayImpl.h.

template<typename T>
exint UT_Array< T >::find ( const T t,
Comparator  compare 
) const

Definition at line 704 of file UT_ArrayImpl.h.

template<typename T>
exint UT_Array< T >::findAndRemove ( const T t)

Remove one element from the array given the element itself or its position in the list, and fill the gap by shifting the elements down by one position. Return the index of the element remove or -1 if the value was not found.

Definition at line 500 of file UT_ArrayImpl.h.

template<class T>
T UT_Array< T >::forcedGet ( exint  i) const
inline

forcedGet(exint) does NOT grow the array, and will return default objects for out of bound array indices.

Definition at line 586 of file UT_Array.h.

template<class T>
T& UT_Array< T >::forcedRef ( exint  i)
inline

forcedRef(exint) will grow the array if necessary, initializing any new elements to zero for POD types and default constructing for class types.

Definition at line 576 of file UT_Array.h.

template<class T>
T* UT_Array< T >::getArray ( ) const
inline

Definition at line 611 of file UT_Array.h.

template<class T>
int64 UT_Array< T >::getMemoryUsage ( bool  inclusive = false) const
inline

Returns the amount of memory used by this UT_Array. If inclusive is false, it only counts the memory of the array. This is often necessary to avoid double-counting, e.g. if this UT_Array is a member variable of a class whose memory is already being counted by the caller.

Definition at line 462 of file UT_Array.h.

template<class T>
const T* UT_Array< T >::getRawArray ( ) const
inline

Definition at line 612 of file UT_Array.h.

template<typename T>
bool UT_Array< T >::hasSortedSubset ( const UT_Array< T > &  other,
Comparator  compare 
) const

Definition at line 1033 of file UT_ArrayImpl.h.

template<class T>
const T& UT_Array< T >::heapMax ( ) const
inline

Assuming the array is already a heap, return the top (maximum) element.

Definition at line 193 of file UT_Array.h.

template<typename T >
T UT_Array< T >::heapPop ( Comparator  compare)

Assuming the array is already a heap, extracts the top (maximum) element from the heap and returns it.

Definition at line 377 of file UT_ArrayImpl.h.

template<typename T>
exint UT_Array< T >::heapPush ( const T t,
Comparator  compare 
)

Assuming the array is already a heap, it inserts item t maintaining the heap. It returns the index of the inserted item.

Definition at line 360 of file UT_ArrayImpl.h.

template<class T>
exint UT_Array< T >::index ( const T t) const
inline

The fastest search possible, which does pointer arithmetic to find the index of the element. WARNING: index() does no out-of-bounds checking.

Definition at line 280 of file UT_Array.h.

template<typename T >
exint UT_Array< T >::insert ( exint  index)

Definition at line 122 of file UT_ArrayImpl.h.

template<class T>
exint UT_Array< T >::insert ( const T t,
exint  i 
)
inline

Definition at line 108 of file UT_Array.h.

template<class T>
exint UT_Array< T >::insert ( T &&  t,
exint  i 
)
inline

Definition at line 110 of file UT_Array.h.

template<class T>
exint UT_Array< T >::insertAt ( const T t,
exint  index 
)
inline

An alias for unique element insertion at a certain index. Also used by the other insertion methods.

Definition at line 207 of file UT_Array.h.

template<typename T >
template<typename S >
exint UT_Array< T >::insertImpl ( S &&  s,
exint  index 
)
protected

Similar to appendImpl() but for insertion.

Definition at line 452 of file UT_ArrayImpl.h.

template<class T>
bool UT_Array< T >::isEmpty ( ) const
inline

Returns true iff there are no occupied elements in the array.

Definition at line 455 of file UT_Array.h.

template<typename T>
int UT_Array< T >::isEqual ( const UT_Array< T > &  a,
Comparator  compare 
) const

Definition at line 928 of file UT_ArrayImpl.h.

template<class T>
bool UT_Array< T >::isHeapBuffer ( ) const
inline

Returns true if the data used by the array was allocated on the heap.

Definition at line 872 of file UT_Array.h.

template<class T>
bool UT_Array< T >::isHeapBuffer ( T data) const
inline

Definition at line 876 of file UT_Array.h.

template<class T>
static constexpr SYS_FORCE_INLINE bool UT_Array< T >::isPOD ( )
inlinestaticprotected

Definition at line 886 of file UT_Array.h.

template<class T>
bool UT_Array< T >::isValidIndex ( exint  index) const
inline

Return true if given index is valid.

Definition at line 211 of file UT_Array.h.

template<class T>
T& UT_Array< T >::last ( )
inline

Definition at line 591 of file UT_Array.h.

template<class T>
const T& UT_Array< T >::last ( ) const
inline

Definition at line 596 of file UT_Array.h.

template<typename T>
template<typename ComparatorBool >
void UT_Array< T >::merge ( const UT_Array< T > &  other,
int  direction,
bool  allow_dups,
ComparatorBool  is_less 
)

Merge the given array into us. If direction is -1, then it assumes us and 'other' are both already sorted in descending order. Similarly, +1 means ascending. If allow_dups is false, then it further assumes that both arrays have no duplicates and will produce a result that also has no duplicates. More work will be needed if you want allow_dups to mean remove duplicates

Definition at line 959 of file UT_ArrayImpl.h.

template<typename T >
void UT_Array< T >::move ( exint  srcIdx,
exint  destIdx,
exint  howMany 
)

Move howMany objects starting at index srcIndex to destIndex; This method will remove the elements at [srcIdx, srcIdx+howMany) and then insert them at destIdx. This method can be used in place of the old shift() operation.

Definition at line 567 of file UT_ArrayImpl.h.

template<typename T >
exint UT_Array< T >::multipleInsert ( exint  index,
exint  count 
)

Insert an element "count" times at the given index. Return the index.

Definition at line 425 of file UT_ArrayImpl.h.

template<typename T>
bool UT_Array< T >::operator!= ( const UT_Array< T > &  a) const

Definition at line 921 of file UT_ArrayImpl.h.

template<class T>
T& UT_Array< T >::operator() ( exint  i)
inline

Subscript operator NOTE: This does NOT do any bounds checking unless paranoid asserts are enabled.

Definition at line 542 of file UT_Array.h.

template<class T>
const T& UT_Array< T >::operator() ( exint  i) const
inline

Const subscript operator NOTE: This does NOT do any bounds checking unless paranoid asserts are enabled.

Definition at line 550 of file UT_Array.h.

template<typename T>
UT_Array< T > & UT_Array< T >::operator= ( const UT_Array< T > &  a)

Assign array a to this array by copying each of a's elements with memcpy for POD types, and with copy construction for class types.

Definition at line 824 of file UT_ArrayImpl.h.

template<typename T>
UT_Array< T > & UT_Array< T >::operator= ( std::initializer_list< T ilist)

Replace the contents with those from the initializer_list ilist.

Definition at line 844 of file UT_ArrayImpl.h.

template<typename T>
UT_Array< T > & UT_Array< T >::operator= ( UT_Array< T > &&  a)

Move the contents of array a to this array.

Definition at line 864 of file UT_ArrayImpl.h.

template<typename T>
bool UT_Array< T >::operator== ( const UT_Array< T > &  a) const

Compare two array and return true if they are equal and false otherwise. Two elements are checked against each other using operator '==' or compare() respectively. NOTE: The capacities of the arrays are not checked when determining whether they are equal.

Definition at line 910 of file UT_ArrayImpl.h.

template<class T>
T& UT_Array< T >::operator[] ( exint  i)
inline

Subscript operator NOTE: This does NOT do any bounds checking unless paranoid asserts are enabled.

Definition at line 559 of file UT_Array.h.

template<class T>
const T& UT_Array< T >::operator[] ( exint  i) const
inline

Const subscript operator NOTE: This does NOT do any bounds checking unless paranoid asserts are enabled.

Definition at line 567 of file UT_Array.h.

template<class T>
UT_IteratorRange<iterator> UT_Array< T >::range ( )
inline

Definition at line 826 of file UT_Array.h.

template<class T>
UT_IteratorRange<const_iterator> UT_Array< T >::range ( ) const
inline

Definition at line 828 of file UT_Array.h.

template<class T>
reverse_iterator UT_Array< T >::rbegin ( )
inline

Begin iterating over the array in reverse.

Definition at line 804 of file UT_Array.h.

template<class T>
const_reverse_iterator UT_Array< T >::rbegin ( ) const
inline

Begin iterating over the array in reverse.

Definition at line 815 of file UT_Array.h.

template<typename T >
template<typename IsEqual >
exint UT_Array< T >::removeIf ( IsEqual  is_equal)

Removes all matching elements from the list, shuffling down and changing the size appropriately. Returns the number of elements left.

Definition at line 619 of file UT_ArrayImpl.h.

template<class T>
exint UT_Array< T >::removeIndex ( exint  index)
inline

Definition at line 219 of file UT_Array.h.

template<class T>
void UT_Array< T >::removeItem ( const reverse_iterator it)
inline

Remove item specified by the reverse_iterator.

Definition at line 837 of file UT_Array.h.

template<class T>
SYS_FORCE_INLINE void UT_Array< T >::removeLast ( )
inline

Definition at line 223 of file UT_Array.h.

template<typename T >
void UT_Array< T >::removeRange ( exint  begin_i,
exint  end_i 
)

Remove the range [begin_i,end_i) of elements from the array.

Definition at line 522 of file UT_ArrayImpl.h.

template<class T>
reverse_iterator UT_Array< T >::rend ( )
inline

End reverse iterator.

Definition at line 810 of file UT_Array.h.

template<class T>
const_reverse_iterator UT_Array< T >::rend ( ) const
inline

End reverse iterator. Consider using it.atEnd() instead.

Definition at line 821 of file UT_Array.h.

template<typename T >
void UT_Array< T >::reverse ( void  )

Reverses the array by swapping elements in mirrored locations.

Definition at line 717 of file UT_ArrayImpl.h.

template<class T>
UT_IteratorRange<reverse_iterator> UT_Array< T >::rrange ( )
inline

Definition at line 831 of file UT_Array.h.

template<class T>
UT_IteratorRange<const_reverse_iterator> UT_Array< T >::rrange ( ) const
inline

Definition at line 833 of file UT_Array.h.

template<class T>
exint UT_Array< T >::safeIndex ( const T t) const
inline

Definition at line 281 of file UT_Array.h.

template<typename T >
template<typename ComparatorBool >
T UT_Array< T >::selectNthLargest ( exint  idx,
ComparatorBool  is_less 
)

Partitions the array into values greater than or less than the Nth element, returns the resulting partition number. idx == 0 will get the minimum value, idx == size()-1 the maximum value. This does modify this array!

Definition at line 734 of file UT_ArrayImpl.h.

template<typename T >
void UT_Array< T >::setCapacity ( exint  newcapacity)

Set the capacity of the array, i.e. grow it or shrink it. The function copies the data after reallocating space for the array.

Definition at line 751 of file UT_ArrayImpl.h.

template<class T>
void UT_Array< T >::setCapacityIfNeeded ( exint  mincapacity)
inline

Definition at line 408 of file UT_Array.h.

template<class T>
void UT_Array< T >::setSize ( exint  newsize)
inline

Set the size, the number of occupied elements in the array. NOTE: This will not do bumpCapacity, so if you call this n times to increase the size, it may take n^2 time.

Definition at line 469 of file UT_Array.h.

template<class T>
void UT_Array< T >::setSizeNoInit ( exint  newsize)
inline

Set the size, but unlike setSize(newsize), this function will not initialize new POD elements to zero. Non-POD data types will still have their constructors called. This function is faster than setSize(ne) if you intend to fill in data for all elements.

Definition at line 492 of file UT_Array.h.

template<class T>
exint UT_Array< T >::size ( void  ) const
inline

Query the size, i.e. the number of occupied elements in the array. NOTE: capacity() >= size().

Examples:
euclid/EUC_Expression.C.

Definition at line 451 of file UT_Array.h.

template<typename T >
void UT_Array< T >::sort ( Comparator  compare)

Sort the array using a comparison function that you must provide. t1 and t2 are pointers to Thing. The comparison function uses strcmp() semantics (i.e. -1 if less than, 0 if equal, 1 if greater).

Definition at line 726 of file UT_ArrayImpl.h.

template<class T>
template<typename ComparatorBool >
void UT_Array< T >::sortAndRemoveDuplicates ( ComparatorBool  is_less)
inline

Sort remove duplicates. Requires that equal elements are adjacent after sorting.

Definition at line 392 of file UT_Array.h.

template<typename T>
exint UT_Array< T >::sortedInsert ( const T t,
Comparator  compare 
)

Assuming the array is sorted, it inserts item t maintaining the sorted state of the array. It returns the index of the inserted item.

Note
This is O(N^2) behaviour if you call it in a loop! Do not use.

Definition at line 219 of file UT_ArrayImpl.h.

template<typename T>
template<typename ComparatorBool >
exint UT_Array< T >::sortedInsert ( const T t,
ComparatorBool  is_less 
)

Assuming the array is sorted, it inserts item t maintaining the sorted state of the array. It returns the index of the inserted item.

Note
This is O(N^2) behaviour if you call it in a loop! Do not use.

Definition at line 245 of file UT_ArrayImpl.h.

template<typename T>
void UT_Array< T >::sortedIntersection ( const UT_Array< T > &  other,
Comparator  compare 
)

Definition at line 1099 of file UT_ArrayImpl.h.

template<typename T>
void UT_Array< T >::sortedIntersection ( const UT_Array< T > &  other,
UT_Array< T > &  result,
Comparator  compare 
) const

Definition at line 1108 of file UT_ArrayImpl.h.

template<typename T >
exint UT_Array< T >::sortedRemoveDuplicates ( )

Assuming this array is sorted, remove all duplicate elements. Returns the number of elements removed.

Definition at line 1207 of file UT_ArrayImpl.h.

template<typename T >
template<typename CompareEqual >
exint UT_Array< T >::sortedRemoveDuplicatesIf ( CompareEqual  compare_equal)

Assuming this array is sorted, remove all duplicate elements using the given binary predicate. Returns the number of elements removed

Definition at line 1173 of file UT_ArrayImpl.h.

template<typename T>
void UT_Array< T >::sortedSetDifference ( const UT_Array< T > &  other,
Comparator  compare 
)

Definition at line 1130 of file UT_ArrayImpl.h.

template<typename T>
void UT_Array< T >::sortedSetDifference ( const UT_Array< T > &  other,
UT_Array< T > &  result,
Comparator  compare 
) const

Definition at line 1139 of file UT_ArrayImpl.h.

template<typename T>
void UT_Array< T >::sortedUnion ( const UT_Array< T > &  other,
Comparator  compare 
)

Definition at line 1045 of file UT_ArrayImpl.h.

template<typename T>
void UT_Array< T >::sortedUnion ( const UT_Array< T > &  other,
UT_Array< T > &  result,
Comparator  compare 
) const

Definition at line 1054 of file UT_ArrayImpl.h.

template<class T>
template<typename I , typename ComparatorBool >
void UT_Array< T >::stableArgSort ( UT_Array< I > &  indices,
ComparatorBool  is_less 
) const
inline

Create an index array from 0..n-1 into this array and sort it with stableSortIndices. The index array will be resized & rebuilt by this.

Definition at line 356 of file UT_Array.h.

template<class T>
template<typename ComparatorBool >
void UT_Array< T >::stableSort ( ComparatorBool  is_less)
inline

stableSort is both stable, so keeps equal elements in the same order (note this is very useful for compatibility between compilers) and templated. Either use a bool sort function or make a utility class with bool operator()(const T a, const T b) the utility class lets you bind data to avoid globals. The comparator returns true if a must occur before b in the list. For sorting ascending, this is a less than operation.

Definition at line 308 of file UT_Array.h.

template<class T>
template<typename K , typename ComparatorBool >
void UT_Array< T >::stableSortByKey ( const UT_Array< K > &  keys,
ComparatorBool  is_less 
)
inline

Sorts this array by an external key array. We assume a 1:1 corespondence between our own elements and those of the key array. The comparator should be defined on the key type.

Definition at line 369 of file UT_Array.h.

template<class T>
template<typename I , typename ComparatorBool >
void UT_Array< T >::stableSortIndices ( UT_Array< I > &  indices,
ComparatorBool  is_less 
) const
inline

Sort indices array by the values indexed into this array using a stable sorting algorithm. To reorder the array in such a way that it would be sorted, or another array to be reordered the same way, include UT_Permute.h and use: UTinversePermute(values.getArray(), indices.getArray(), values.size()); The ComparatorBool uses the less-than semantics. I must be an integer type.

Definition at line 344 of file UT_Array.h.

template<class T>
template<typename ComparatorBool >
void UT_Array< T >::stdsort ( ComparatorBool  is_less)
inline

Sort using std::sort. The ComparatorBool uses the less-than semantics.

Definition at line 294 of file UT_Array.h.

template<typename T>
void UT_Array< T >::swap ( UT_Array< T > &  other)

Definition at line 112 of file UT_ArrayImpl.h.

template<class T>
static void UT_Array< T >::trivialConstruct ( T dst)
inlinestaticprotected

Element Constructor.

Definition at line 954 of file UT_Array.h.

template<class T>
static void UT_Array< T >::trivialConstructRange ( T dst,
exint  n 
)
inlinestaticprotected

Definition at line 961 of file UT_Array.h.

template<class T>
static SYS_FORCE_INLINE void UT_Array< T >::trivialDestruct ( T dst)
inlinestaticprotected

Element Destructor.

Definition at line 984 of file UT_Array.h.

template<class T>
static void UT_Array< T >::trivialDestructRange ( T dst,
exint  n 
)
inlinestaticprotected

Definition at line 989 of file UT_Array.h.

template<class T>
void UT_Array< T >::truncate ( exint  maxsize)
inline

Decreases, but never expands, to the given maxsize.

Definition at line 507 of file UT_Array.h.

template<typename T>
exint UT_Array< T >::uniqueSortedFind ( const T item,
Comparator  compare 
) const

Convenience method to perform binary search of a ascending sorted array with no duplicates. Returns the index of the specified item, -1 if not found.

Definition at line 338 of file UT_ArrayImpl.h.

template<typename T>
template<typename ComparatorBool >
exint UT_Array< T >::uniqueSortedFind ( const T item,
ComparatorBool  is_less 
) const

Definition at line 316 of file UT_ArrayImpl.h.

template<typename T>
exint UT_Array< T >::uniqueSortedInsert ( const T t,
Comparator  compare 
)

Definition at line 270 of file UT_ArrayImpl.h.

template<typename T>
template<typename ComparatorBool >
exint UT_Array< T >::uniqueSortedInsert ( const T t,
ComparatorBool  is_less 
)

Definition at line 293 of file UT_ArrayImpl.h.

template<class T>
void UT_Array< T >::unsafeClearData ( )
inline

Definition at line 864 of file UT_Array.h.

template<class T>
void UT_Array< T >::unsafeShareData ( UT_Array< T > &  src)
inline

Very dangerous methods to share arrays. The array is not aware of the sharing, so ensure you clear out the array prior a destructor or setCapacity operation.

Definition at line 846 of file UT_Array.h.

template<class T>
void UT_Array< T >::unsafeShareData ( T src,
exint  srcsize 
)
inline

Definition at line 852 of file UT_Array.h.

template<class T>
void UT_Array< T >::unsafeShareData ( T src,
exint  size,
exint  capacity 
)
inline

Definition at line 858 of file UT_Array.h.

template<class T>
template<typename First , typename... Rest>
void UT_Array< T >::validateEmplaceArgs ( First &&  first,
Rest &&...  rest 
) const
inlineprotected

In debug builds, verifies that the arguments to emplace_back() will not be invalidated when realloc() is called.

Definition at line 904 of file UT_Array.h.

template<class T>
void UT_Array< T >::validateEmplaceArgs ( ) const
inlineprotected

Base case for validateEmplaceArgs().

Definition at line 917 of file UT_Array.h.

template<typename T >
void UT_Array< T >::zero ( )

Zeros the array if a POD type, else trivial constructs if a class type.

Definition at line 683 of file UT_ArrayImpl.h.

Friends And Related Function Documentation

template<class T>
template<typename OS , typename S >
OS& operator<< ( OS &  os,
const UT_Array< S > &  d 
)
friend

Definition at line 1066 of file UT_Array.h.

template<class T>
void swap ( UT_Array< T > &  a,
UT_Array< T > &  b 
)
friend

Friend specialization of std::swap() to use UT_String::swap()

Definition at line 1020 of file UT_Array.h.


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