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) noexcept
 Move constructor. Steals the working data from the original. More...
 
 UT_Array (const exint capacity, const exint size)
 Construct based on given capacity and size. More...
 
 UT_Array (const exint capacity=0)
 Construct based on given capacity with a size of 0. More...
 
 UT_Array (std::initializer_list< T > init)
 
 ~UT_Array ()
 
void swap (UT_Array< T > &other)
 
exint append ()
 
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 = Less<T>, typename = IsBoolComp<ComparatorBool>>
exint uniqueSortedInsert (const T &t, ComparatorBool is_less={})
 
exint uniqueSortedInsert (T &&t, Comparator compare)
 
template<typename ComparatorBool = Less<T>, typename = IsBoolComp<ComparatorBool>>
exint uniqueSortedFind (const T &item, ComparatorBool is_less={}) const
 
exint uniqueSortedFind (const T &item, Comparator compare) const
 
template<typename ComparatorBool = Less<T>>
void merge (const UT_Array< T > &other, int direction, bool allow_dups, ComparatorBool is_less={})
 
template<typename ComparatorBool = Less<T>, typename = IsBoolComp<ComparatorBool>>
bool hasSortedSubset (const UT_Array< T > &other, ComparatorBool is_less={}) const
 
template<typename ComparatorBool = Less<T>, typename = IsBoolComp<ComparatorBool>>
void sortedUnion (const UT_Array< T > &other, ComparatorBool is_less={})
 
template<typename ComparatorBool = Less<T>, typename = IsBoolComp<ComparatorBool>>
void sortedUnion (const UT_Array< T > &other, UT_Array< T > &result, ComparatorBool is_less={}) const
 
template<typename ComparatorBool = Less<T>, typename = IsBoolComp<ComparatorBool>>
void sortedIntersection (const UT_Array< T > &other, ComparatorBool is_less={})
 
template<typename ComparatorBool = Less<T>, typename = IsBoolComp<ComparatorBool>>
void sortedIntersection (const UT_Array< T > &other, UT_Array< T > &result, ComparatorBool is_less={}) const
 
template<typename ComparatorBool = Less<T>, typename = IsBoolComp<ComparatorBool>>
void sortedSetDifference (const UT_Array< T > &other, ComparatorBool is_less={})
 
template<typename ComparatorBool = Less<T>, typename = IsBoolComp<ComparatorBool>>
void sortedSetDifference (const UT_Array< T > &other, UT_Array< T > &result, ComparatorBool is_less={}) const
 
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 concat (UT_Array< T > &&a) noexcept
 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...
 
template<typename S >
exint findAndRemove (const S &s)
 
exint removeIndex (exint index)
 
SYS_FORCE_INLINE void removeLast ()
 
void removeRange (exint begin_i, exint end_i)
 
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 src_idx, exint dst_idx, exint how_many)
 
void cycle (exint how_many)
 Cyclically shifts the entire array by how_many. 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...
 
template<typename S >
exint find (const S &s, exint start=0) const
 
exint sortedFind (const T &t, Comparator compare) const
 
void reverse ()
 Reverses the array by swapping elements in mirrored locations. More...
 
template<typename ComparatorBool = Less<T>, typename = IsBoolComp<ComparatorBool>>
void sort (ComparatorBool is_less={})
 Sort using std::sort with bool comparator. Defaults to operator<(). More...
 
void sort (Comparator compare)
 
template<typename ComparatorBool , typename = IsBoolComp<ComparatorBool>>
void stdsort (ComparatorBool is_less)
 Sort using std::sort. The ComparatorBool uses the less-than semantics. More...
 
template<typename ComparatorBool = Less<T>>
void stableSort (ComparatorBool is_less={})
 
template<typename ComparatorBool >
void stableSortRange (ComparatorBool is_less, exint start, exint end)
 Like stableSort, but operates on a subset of the array. More...
 
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 = Less<T>>
exint sortAndRemoveDuplicates (ComparatorBool is_less={})
 
template<typename ComparatorBool = Less<T>>
T selectNthLargest (exint idx, ComparatorBool is_less={})
 
void setCapacity (exint new_capacity)
 
void setCapacityIfNeeded (exint min_capacity)
 
void bumpCapacity (exint min_capacity)
 
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 setSizeIfNeeded (exint minsize)
 
void entries (exint newsize)
 Alias of setSize(). setSize() is preferred. More...
 
void setSizeNoInit (exint newsize)
 
void shrinkToFit ()
 shrinks the capacity to the current size More...
 
void setSizeAndShrink (exint new_size)
 convenience method to set size and shrink-to-fit in a single call More...
 
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
 
template<typename ComparatorBool , typename = IsBoolComp<ComparatorBool>>
bool isEqual (const UT_Array< T > &a, ComparatorBool is_equal) 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(*apply_func)(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...
 
exint sortedInsert (const T &t, Comparator compare)
 
template<typename ComparatorBool = Less<T>, typename = IsBoolComp<ComparatorBool>>
exint sortedInsert (const T &t, ComparatorBool is_less={})
 
exint index (const T &t) const
 
exint safeIndex (const T &t) const
 

Protected Member Functions

 UT_Array (const UT_ArrayCT::ExternalCapacity, T *external_data, const exint external_capacity)
 
 UT_Array (const UT_ArrayCT::ExternalMove, T *external_data, const exint external_capacity, UT_Array &&a)
 
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 S >
exint uniqueSortedInsertImpl (S &&s, Comparator compare)
 
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)
 

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 95 of file UT_Array.h.

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

Definition at line 999 of file UT_Array.h.

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

Definition at line 1001 of file UT_Array.h.

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

Definition at line 998 of file UT_Array.h.

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

Definition at line 1000 of file UT_Array.h.

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

Definition at line 1002 of file UT_Array.h.

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

Definition at line 93 of file UT_Array.h.

Constructor & Destructor Documentation

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

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 519 of file UT_ArrayImpl.h.

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

Move constructor. Steals the working data from the original.

Definition at line 551 of file UT_ArrayImpl.h.

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

Construct based on given capacity and size.

Definition at line 558 of file UT_ArrayImpl.h.

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

Construct based on given capacity with a size of 0.

Definition at line 569 of file UT_ArrayImpl.h.

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

Construct with the contents of an initializer list If you are wondering why we mark this as explicit... Imagine you have the following: void foo(int i); // 1 void foo(UT_Array<int>); // 2 Without explicit you can do this foo({1}) and function 1 will be called when you probably meant for function 2 to be called.

Definition at line 535 of file UT_ArrayImpl.h.

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

Definition at line 578 of file UT_ArrayImpl.h.

template<typename T>
UT_Array< T >::UT_Array ( const UT_ArrayCT::ExternalCapacity  ,
T external_data,
const exint  external_capacity 
)
explicitprotected

Definition at line 595 of file UT_ArrayImpl.h.

template<typename T>
UT_Array< T >::UT_Array ( const UT_ArrayCT::ExternalMove  ,
T external_data,
const exint  external_capacity,
UT_Array< T > &&  a 
)
explicitprotected

Definition at line 607 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
inline

Definition at line 1845 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 capacity(). Use caution with this method.

Definition at line 847 of file UT_Array.h.

template<class T>
exint UT_Array< T >::append ( )
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, OPUI/OPUI_MemUsageTextBadge.C, and SOP/SOP_BouncyAgent.C.

Definition at line 142 of file UT_Array.h.

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

Definition at line 143 of file UT_Array.h.

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

Definition at line 144 of file UT_Array.h.

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

Definition at line 145 of file UT_Array.h.

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

Definition at line 786 of file UT_ArrayImpl.h.

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

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 746 of file UT_ArrayImpl.h.

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

Definition at line 795 of file UT_ArrayImpl.h.

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

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

Definition at line 1549 of file UT_ArrayImpl.h.

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

Definition at line 839 of file UT_Array.h.

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

Definition at line 840 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 1006 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 1019 of file UT_Array.h.

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

If the capacity is smaller than min_capacity, expand the array to at least min_capacity 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 612 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 636 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 629 of file UT_Array.h.

template<typename T >
exint UT_Array< T >::capacity ( ) const

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

Definition at line 143 of file UT_ArrayImpl.h.

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

Resets list to an empty list.

Definition at line 729 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 408 of file UT_Array.h.

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

Takes another T array and concatenate it onto my end.

Definition at line 982 of file UT_ArrayImpl.h.

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

Takes another T array and concatenate it onto my end.

Definition at line 993 of file UT_ArrayImpl.h.

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

Quickly set the array to a single value.

Definition at line 1272 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 1150 of file UT_Array.h.

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

Definition at line 1156 of file UT_Array.h.

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

Cyclically shifts the entire array by how_many.

Definition at line 1244 of file UT_ArrayImpl.h.

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

Definition at line 842 of file UT_Array.h.

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

Definition at line 843 of file UT_Array.h.

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

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 769 of file UT_ArrayImpl.h.

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

End iterator.

Definition at line 1011 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 1024 of file UT_Array.h.

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

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

Examples:
SIM/GAS_NetVDBSliceExchange.C.

Definition at line 648 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 686 of file UT_Array.h.

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

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. begin_i is the start index, end_i is index to stop at, and isn't inclusive.

Definition at line 1126 of file UT_ArrayImpl.h.

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

Search for s linearly using the '==' operator, starting at index start.

Returns
the index of the matching element or (exint)-1.

Definition at line 1302 of file UT_ArrayImpl.h.

template<typename T >
template<typename S >
exint UT_Array< T >::findAndRemove ( const S s)
inline

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 1087 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 811 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 801 of file UT_Array.h.

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

Definition at line 836 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 657 of file UT_Array.h.

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

Definition at line 837 of file UT_Array.h.

template<typename T>
template<typename ComparatorBool , typename >
bool UT_Array< T >::hasSortedSubset ( const UT_Array< T > &  other,
ComparatorBool  is_less = {} 
) const
inline

Definition at line 1653 of file UT_ArrayImpl.h.

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

Definition at line 1643 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 346 of file UT_Array.h.

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

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

Definition at line 945 of file UT_ArrayImpl.h.

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

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 928 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 445 of file UT_Array.h.

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

Definition at line 721 of file UT_ArrayImpl.h.

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

Definition at line 155 of file UT_Array.h.

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

Definition at line 157 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 362 of file UT_Array.h.

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

Similar to appendImpl() but for insertion.

Definition at line 1039 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 650 of file UT_Array.h.

template<typename T>
template<typename ComparatorBool , typename >
bool UT_Array< T >::isEqual ( const UT_Array< T > &  a,
ComparatorBool  is_equal 
) const
inline

Definition at line 1529 of file UT_ArrayImpl.h.

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

Definition at line 1542 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 1099 of file UT_Array.h.

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

Definition at line 1109 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 366 of file UT_Array.h.

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

Definition at line 816 of file UT_Array.h.

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

Definition at line 821 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 = {} 
)
inline

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 1569 of file UT_ArrayImpl.h.

template<typename T >
void UT_Array< T >::move ( exint  src_idx,
exint  dst_idx,
exint  how_many 
)
inline

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

Definition at line 1162 of file UT_ArrayImpl.h.

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

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

Definition at line 1013 of file UT_ArrayImpl.h.

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

Definition at line 1521 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 767 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 775 of file UT_Array.h.

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

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 1455 of file UT_ArrayImpl.h.

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

Replace the contents with those from the initializer_list ilist.

Definition at line 1470 of file UT_ArrayImpl.h.

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

Move the contents of array a to this array.

Definition at line 1490 of file UT_ArrayImpl.h.

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

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 1510 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 784 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 792 of file UT_Array.h.

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

Definition at line 1053 of file UT_Array.h.

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

Definition at line 1055 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 1031 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 1042 of file UT_Array.h.

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

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

Definition at line 1212 of file UT_ArrayImpl.h.

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

Definition at line 375 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 1064 of file UT_Array.h.

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

Definition at line 379 of file UT_Array.h.

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

Remove the range [begin_i,end_i) of elements from the array. begin_i is the start index. end_i is the index to stop at, and isn't inclusive.

Definition at line 1108 of file UT_ArrayImpl.h.

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

End reverse iterator.

Definition at line 1037 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 1048 of file UT_Array.h.

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

Reverses the array by swapping elements in mirrored locations.

Definition at line 1327 of file UT_ArrayImpl.h.

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

Definition at line 1058 of file UT_Array.h.

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

Definition at line 1060 of file UT_Array.h.

template<class T>
exint UT_Array< T >::safeIndex ( 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 446 of file UT_Array.h.

template<typename T >
template<typename ComparatorBool >
T UT_Array< T >::selectNthLargest ( exint  idx,
ComparatorBool  is_less = {} 
)
inline

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 1344 of file UT_ArrayImpl.h.

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

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 1361 of file UT_ArrayImpl.h.

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

Definition at line 603 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 666 of file UT_Array.h.

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

convenience method to set size and shrink-to-fit in a single call

Definition at line 716 of file UT_Array.h.

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

Definition at line 679 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 695 of file UT_Array.h.

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

shrinks the capacity to the current size

Definition at line 710 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 646 of file UT_Array.h.

template<class T>
template<typename ComparatorBool = Less<T>, typename = IsBoolComp<ComparatorBool>>
void UT_Array< T >::sort ( ComparatorBool  is_less = {})
inline

Sort using std::sort with bool comparator. Defaults to operator<().

Definition at line 456 of file UT_Array.h.

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

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 1336 of file UT_ArrayImpl.h.

template<class T>
template<typename ComparatorBool = Less<T>>
exint UT_Array< T >::sortAndRemoveDuplicates ( ComparatorBool  is_less = {})
inline

Sort and then remove duplicates. By default, operator<() is used but if you supply a custom comparator, ensure that equal elements are adjacent after sorting. Returns the number of elements removed.

Definition at line 587 of file UT_Array.h.

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

Search for t via binary search using the function specified in the parameter list, assuming the array is already sorted with respect to compare.

Returns
the index of the matching element or (exint)-1.

Definition at line 1313 of file UT_ArrayImpl.h.

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

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 819 of file UT_ArrayImpl.h.

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

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 827 of file UT_ArrayImpl.h.

template<typename T>
template<typename ComparatorBool , typename >
void UT_Array< T >::sortedIntersection ( const UT_Array< T > &  other,
ComparatorBool  is_less = {} 
)
inline

Definition at line 1744 of file UT_ArrayImpl.h.

template<typename T>
template<typename ComparatorBool , typename >
void UT_Array< T >::sortedIntersection ( const UT_Array< T > &  other,
UT_Array< T > &  result,
ComparatorBool  is_less = {} 
) const
inline

Definition at line 1756 of file UT_ArrayImpl.h.

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

Definition at line 1682 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
inline

Definition at line 1689 of file UT_ArrayImpl.h.

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

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

Definition at line 1836 of file UT_ArrayImpl.h.

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

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

Definition at line 1802 of file UT_ArrayImpl.h.

template<typename T>
template<typename ComparatorBool , typename >
void UT_Array< T >::sortedSetDifference ( const UT_Array< T > &  other,
ComparatorBool  is_less = {} 
)
inline

Definition at line 1773 of file UT_ArrayImpl.h.

template<typename T>
template<typename ComparatorBool , typename >
void UT_Array< T >::sortedSetDifference ( const UT_Array< T > &  other,
UT_Array< T > &  result,
ComparatorBool  is_less = {} 
) const
inline

Definition at line 1785 of file UT_ArrayImpl.h.

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

Definition at line 1699 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
inline

Definition at line 1706 of file UT_ArrayImpl.h.

template<typename T>
template<typename ComparatorBool , typename >
void UT_Array< T >::sortedUnion ( const UT_Array< T > &  other,
ComparatorBool  is_less = {} 
)
inline

Definition at line 1717 of file UT_ArrayImpl.h.

template<typename T>
template<typename ComparatorBool , typename >
void UT_Array< T >::sortedUnion ( const UT_Array< T > &  other,
UT_Array< T > &  result,
ComparatorBool  is_less = {} 
) const
inline

Definition at line 1727 of file UT_ArrayImpl.h.

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

Definition at line 1665 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
inline

Definition at line 1672 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 549 of file UT_Array.h.

template<class T>
template<typename ComparatorBool = Less<T>>
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 485 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 562 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 537 of file UT_Array.h.

template<class T>
template<typename ComparatorBool >
void UT_Array< T >::stableSortRange ( ComparatorBool  is_less,
exint  start,
exint  end 
)
inline

Like stableSort, but operates on a subset of the array.

Definition at line 496 of file UT_Array.h.

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

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

Definition at line 471 of file UT_Array.h.

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

Definition at line 676 of file UT_ArrayImpl.h.

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

Decreases, but never expands, to the given maxsize.

Definition at line 723 of file UT_Array.h.

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

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 899 of file UT_ArrayImpl.h.

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

Definition at line 921 of file UT_ArrayImpl.h.

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

Definition at line 233 of file UT_Array.h.

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

Definition at line 876 of file UT_ArrayImpl.h.

template<class T>
exint UT_Array< T >::uniqueSortedInsert ( T &&  t,
Comparator  compare 
)
inline

Definition at line 242 of file UT_Array.h.

template<typename T >
template<typename S >
exint UT_Array< T >::uniqueSortedInsertImpl ( S &&  s,
Comparator  compare 
)
inlineprotected

Definition at line 853 of file UT_ArrayImpl.h.

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

Definition at line 1091 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 1073 of file UT_Array.h.

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

Definition at line 1079 of file UT_Array.h.

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

Definition at line 1085 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 1131 of file UT_Array.h.

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

Base case for validateEmplaceArgs().

Definition at line 1144 of file UT_Array.h.

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

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

Definition at line 1287 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 1426 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 1374 of file UT_Array.h.


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