-
首页
-
C4D R23.110 C++ SDK
ArrayInterface< TYPE > Class Template Reference
#include <array.h>
详细描述
template<typename TYPE>
class maxon::ArrayInterface< TYPE >
ArrayInterface
is an interface which provides the usual array functions as virtual methods. Each standard array of the MAXON API can be represented as such an interface, so this allows to write non-template functions which nevertheless are able to deal with any kind of array.
If the function won't modify both the structure and values of the array, you should use a
const
ArrayInterface
with
const
elements:
void
Func(
const
ArrayInterface<const Char>& array);
BlockArray<Char> myArray;
Func(myArray);
// OK
BaseArray<Char> myArray2;
Func(myArray2);
// OK
As the access to the array happens via virtual methods, there is an inevitable performance penalty. Often this will be negligible, but if not, you can use the GetBlock function to obtain a fraction of the array as a
Block
of array elements which are laid out regularly in memory. Then as long as the elements you need to access are within that same block, no further virtual method invocations are necessary. E.g., a
BaseArray
consists of just a single block, and a
BlockArray
of a small number of blocks (small compared to the number of elements). The iterator of an
ArrayInterface
already takes this into account, so it uses the minimum possible number of virtual method invocations.
For an array which shall be modified, use WritableArrayInterface as type of the function parameter instead.
-
Template Parameters
-
TYPE
|
Type of elements of the array.
|
公共成员函数
|
TYPE &
|
operator[]
(
Int
index)
|
MAXON_METHOD
Int
|
GetBlock
(
Int
index,
Block
< const TYPE > &block) const
|
Int
|
GetBlock
(
Int
index,
Block
< typename
Super::NonConstValueType
> &block)
|
MAXON_METHOD
Result
< void >
|
PrivateInsert
(
Int
index, const
StridedBlock
< const TYPE > &values,
Bool
move)
|
MAXON_METHOD
ResultMem
|
Resize
(
Int
count,
COLLECTION_RESIZE_FLAGS
resizeFlags=
COLLECTION_RESIZE_FLAGS::DEFAULT
)
|
MAXON_METHOD
ResultMem
|
SetCapacityHint
(
Int
requestedCapacity,
COLLECTION_RESIZE_FLAGS
resizeFlags=
COLLECTION_RESIZE_FLAGS::ON_GROW_RESERVE_CAPACITY
)
|
MAXON_METHOD
ResultRef
< TYPE >
|
Insert
(
Int
index)
|
MAXON_FUNCTION
ResultRef
< TYPE >
|
Insert
(
Int
index, const TYPE &value)
|
MAXON_FUNCTION
ResultRef
< TYPE >
|
Insert
(
Int
index, TYPE &&value)
|
MAXON_METHOD
ResultMem
|
Insert
(
Int
index, const
Block
< const TYPE > &values)
|
MAXON_METHOD
ResultMem
|
Insert
(
Int
index, const
MoveBlock
< TYPE > &values)
|
MAXON_METHOD
ResultRef
< TYPE >
|
Append
()
|
MAXON_FUNCTION
ResultRef
< TYPE >
|
Append
(const TYPE &value)
|
MAXON_FUNCTION
ResultRef
< TYPE >
|
Append
(TYPE &&value)
|
template<typename A >
|
MAXON_FUNCTION
ResultRef
< TYPE >
|
Append
(A &&value)
|
MAXON_FUNCTION
Bool
|
Pop
()
|
MAXON_FUNCTION
Bool
|
Pop
(TYPE *dst)
|
MAXON_METHOD
ResultMem
|
Erase
(
Int
index,
Int
count=1)
|
template<typename C >
|
ArrayInterface::template
IteratorTemplate
< C >
|
Erase
(const typename ArrayInterface::template
IteratorTemplate
< C > &it)
|
MAXON_METHOD
ResultMem
|
SwapErase
(
Int
index,
Int
count=1)
|
MAXON_METHOD
void
|
重置
()
|
MAXON_METHOD
void
|
Flush
()
|
MAXON_METHOD
Result
< void >
|
CopyFrom
(const
ArrayInterface
&other)
|
MAXON_METHOD
void
|
SetPersistentIdGenerator
(const PersistentIdGenerator &generator)
|
MAXON_METHOD
Int
|
GetMemorySize
() const
|
template<typename DT >
|
MAXON_FUNCTION
Bool
|
HasType
() const
|
template<typename DT >
|
MAXON_FUNCTION
void
|
AssertType
() const
|
template<typename T2 >
|
ArrayInterface
< T2 > &
|
AssertCast
()
|
template<typename T2 >
|
const
ArrayInterface
< T2 > &
|
AssertCast
() const
|
|
operator const ArrayInterface< const TYPE > &
() const
|
|
operator const ArrayInterface< typename std::conditional< STD_IS_REPLACEMENT
(same, const TYPE, const Generic)
|
const const Generic ::
type
&const
|
operator ArrayInterface< typename std::conditional< STD_IS_REPLACEMENT
(same, TYPE, Generic)
|
const const Generic ::
type
&const Generic ::
type
&
|
operator const NonConstArray< TYPE > &
()
|
|
operator const NonConstArray< typename std::conditional< STD_IS_REPLACEMENT
(same, TYPE, Generic)
|
MAXON_FUNCTION
ArrayInterface
< TYPE >::
ConstIterator
|
Begin
() const
|
Iterator
|
Begin
()
|
MAXON_FUNCTION
ArrayInterface
< TYPE >::
ConstIterator
|
End
() const
|
Iterator
|
End
()
|
MAXON_METHOD
Int
|
GetBlock
(
Int
index,
SimdBlock
< const TYPE > &block) const
|
Int
|
GetBlock
(
Int
index,
StridedBlock
< const TYPE > &block) const
|
Int
|
GetBlock
(
Int
index,
Block
< const TYPE, false > &block) const
|
MAXON_METHOD
Result
<
Int
>
|
GetBlock
(
Int
index,
SimdBlock
<
NonConstValueType
> &block)
|
Int
|
GetBlock
(
Int
index,
StridedBlock
<
NonConstValueType
> &block)
|
MAXON_ATTRIBUTE_FORCE_INLINE
|
ArrayBase0
(ARGS &&... args)
|
Bool
|
IsValidIndex
(
Int
index) const
|
Result
< void >
|
CheckValidIndex
(
Int
index) const
|
Int
|
FindIndex
(typename
ByValueParam
<
TYPE
>::
type
v,
Int
start) const
|
Int
|
FindLastIndex
(typename
ByValueParam
<
TYPE
>::
type
v) const
|
Int
|
FindLastIndex
(typename
ByValueParam
<
TYPE
>::
type
v,
Int
start) const
|
Bool
|
EraseFirst
(typename
ByValueParam
<
TYPE
>::
type
v)
|
Int
|
EraseAll
(typename
ByValueParam
<
TYPE
>::
type
v)
|
Result
< void >
|
AppendAllImpl
(COLLECTION2 &&other,
COLLECTION_RESIZE_FLAGS
resizeFlags,
Bool
overwrite,
OverloadRank0
)
|
Result
< void >
|
InsertAll
(
Int
index, COLLECTION2 &&other,
COLLECTION_RESIZE_FLAGS
resizeFlags=
COLLECTION_RESIZE_FLAGS::ON_GROW_RESERVE_CAPACITY
)
|
Result
< void >
|
添加
(COLLECTION2 &&other,
COLLECTION_RESIZE_FLAGS
resizeFlags=
COLLECTION_RESIZE_FLAGS::ON_GROW_RESERVE_CAPACITY
)
|
Result
< void >
|
SubtractImpl
(COLLECTION2 &&other,
OverloadRank0
)
|
Bool
|
IsEqualImpl
(const COLLECTION2 &other, COMPARE &&cmp,
OverloadRank0
) const
|
HashInt
|
GetHashCode
() const
|
MAXON_ATTRIBUTE_FORCE_INLINE
AutoIterator
<
ArrayInterface
<
TYPE
> >
|
切片
(
Int
start)
|
MAXON_ATTRIBUTE_FORCE_INLINE
AutoIterator
< const
ArrayInterface
<
TYPE
> >
|
切片
(
Int
start) const
|
MAXON_ATTRIBUTE_FORCE_INLINE
AutoIterator
<
ArrayInterface
<
TYPE
> >
|
切片
(
Int
start,
Int
end)
|
MAXON_ATTRIBUTE_FORCE_INLINE
AutoIterator
< const
ArrayInterface
<
TYPE
> >
|
切片
(
Int
start,
Int
end) const
|
BlockIterator
<
ArrayInterface
<
TYPE
>,
TYPE
, false, false >
|
GetBlocks
()
|
BlockIterator
<
ArrayInterface
<
TYPE
>,
TYPE
, true, false >
|
GetBlocks
() const
|
BlockIterator
<
ArrayInterface
<
TYPE
>,
TYPE
, false, true >
|
GetStridedBlocks
()
|
BlockIterator
<
ArrayInterface
<
TYPE
>,
TYPE
, true, true >
|
GetStridedBlocks
() const
|
MAXON_ATTRIBUTE_FORCE_INLINE
|
Collection
(ARGS &&... args)
|
ResultOk
< void >
|
VariadicAppend
()
|
Result
< void >
|
VariadicAppend
(V &&value, VALUES &&... rest)
|
|
operator ValueReceiver< const TYPE & >
()
|
|
operator ValueReceiver< TYPE && >
()
|
|
operator ValueReceiver< typename std::conditional< STD_IS_REPLACEMENT
(scalar,
TYPE
)
|
DummyParamType &
|
type
()
|
Result
<
Bool
>
|
ForEach
(FN &&callback) const
|
Result
<
Bool
>
|
ForEach
(FN &&callback)
|
H::Iterator
|
Find
(typename
ByValueParam
<
TYPE
>::
type
v)
|
H::ConstIterator
|
Find
(typename
ByValueParam
<
TYPE
>::
type
v) const
|
Int
|
FindIndex
(typename
ByValueParam
<
TYPE
>::
type
v) const
|
MAXON_ATTRIBUTE_FORCE_INLINE
Bool
|
Contains
(typename
ByValueParam
<
TYPE
>::
type
v) const
|
MAXON_ATTRIBUTE_FORCE_INLINE
|
BaseCollection
(ARGS &&... args)
|
MAXON_ATTRIBUTE_FORCE_INLINE
std::enable_if< maxon::IsCollection< COLLECTION2 >::value,
Bool
>::type
|
operator==
(const COLLECTION2 &other) const
|
MAXON_ATTRIBUTE_FORCE_INLINE
std::enable_if< maxon::IsCollection< COLLECTION2 >::value,
Bool
>::type
|
operator!=
(const COLLECTION2 &other) const
|
MAXON_ATTRIBUTE_FORCE_INLINE
std::enable_if< maxon::IsCollection< COLLECTION2 >::value &&!
STD_IS_REPLACEMENT
(same, typename std::decay< COMPARE >::type,
EQUALITY
),
Bool
>::type
|
IsEqual
(const COLLECTION2 &other, COMPARE &&cmp=COMPARE()) const
|
MAXON_ATTRIBUTE_FORCE_INLINE
Result
< void >
|
AppendAll
(COLLECTION2 &&other,
COLLECTION_RESIZE_FLAGS
resizeFlags=
COLLECTION_RESIZE_FLAGS::ON_GROW_RESERVE_CAPACITY
)
|
MAXON_ATTRIBUTE_FORCE_INLINE
Result
< void >
|
CopyFrom
(COLLECTION2 &&other,
COLLECTION_RESIZE_FLAGS
resizeFlags=
COLLECTION_RESIZE_FLAGS::FIT_TO_SIZE
)
|
MAXON_ATTRIBUTE_FORCE_INLINE
Result
< void >
|
Subtract
(COLLECTION2 &&other)
|
MAXON_ATTRIBUTE_FORCE_INLINE
Result
< void >
|
Intersect
(const COLLECTION2 &other)
|
Bool
|
Intersects
(const COLLECTION2 &other) const
|
MAXON_ATTRIBUTE_FORCE_INLINE
Result
< void >
|
CopyFromImpl
(COLLECTION2 &&other,
COLLECTION_RESIZE_FLAGS
resizeFlags,
OverloadRank0
)
|
Result
< void >
|
AppendAllImpl
(COLLECTION2 &&other,
COLLECTION_RESIZE_FLAGS
resizeFlags,
Bool
overwrite,
OverloadRank0
)
|
Result
< void >
|
IntersectImpl
(COLLECTION2 &&other,
OverloadRank0
)
|
MAXON_ATTRIBUTE_FORCE_INLINE
Bool
|
IsEmpty
() const
|
MAXON_ATTRIBUTE_FORCE_INLINE
Bool
|
IsPopulated
() const
|
String
|
ToString
(const
FormatStatement
*formatStatement=nullptr) const
|
MAXON_ATTRIBUTE_FORCE_INLINE
Bool
|
ContainsAll
(COLLECTION2 &&other) const
|
Bool
|
ContainsAllImpl
(COLLECTION2 &&other,
OverloadRank0
) const
|
MAXON_METHOD
Int
|
GetCount
() const
|
MAXON_FUNCTION
Bool
|
IsEmpty
() const
|
MAXON_FUNCTION
Bool
|
IsPopulated
() const
|
const
MAXON_METHOD
TYPE &
|
operator[]
(
Int
index) const
|
MAXON_METHOD
ResultRef
< TYPE >
|
GetWritable
(
Int
index)
|
template<typename A >
|
MAXON_FUNCTION
ResultMem
|
Set
(
Int
index, A &&value)
|
MAXON_METHOD
Int
|
GetBlock
(
Int
index,
SimdBlock
< const TYPE > &block) const
|
Int
|
GetBlock
(
Int
index,
StridedBlock
< const TYPE > &block) const
|
Int
|
GetBlock
(
Int
index,
Block
< const TYPE, false > &block) const
|
MAXON_METHOD
Result
<
Int
>
|
GetBlock
(
Int
index,
SimdBlock
<
NonConstValueType
> &block)
|
Int
|
GetBlock
(
Int
index,
StridedBlock
<
NonConstValueType
> &block)
|
const
MAXON_METHOD
DataType
&
|
GetValueDataType
() const
|
const
MAXON_METHOD
PersistentIdGenerator &
|
GetPersistentIdGenerator
() const
|
BlockIterator
<
StaticArrayInterface
, TYPE, true, false >
|
GetBlocks
() const
|
BlockIterator
<
StaticArrayInterface
, TYPE, true, true >
|
GetStridedBlocks
() const
|
Int
|
GetValueSize
() const
|
MAXON_FUNCTION
StaticArrayInterface
< TYPE >::
ConstIterator
|
Begin
() const
|
Iterator
|
Begin
()
|
MAXON_FUNCTION
StaticArrayInterface
< TYPE >::
ConstIterator
|
End
() const
|
Iterator
|
End
()
|
Member Typedef Documentation
◆
ValueType
◆
Super
◆
Iterator
◆
ConstIterator
成员函数文档编制
◆
MAXON_INTERFACE_SIMPLE_VIRTUAL_DERIVED()
◆
operator[]()
TYPE& operator[]
|
(
|
Int
|
index
|
)
|
|
◆
GetBlock()
[1/7]
Determines a contiguous non-strided block of array elements which contains the element at
index
. The returned blocks are guaranteed to form a partition of the array, i.e., no two blocks overlap, and they cover the whole array.
Using this method can greatly reduce the performance penalty of virtual method invocations of the
Array
interface as only one such invocation has to happen per block, and a block may consist of a relatively large number of elements which can then be accessed directly.
-
参数
-
[in]
|
index
|
Element index.
|
[out]
|
block
|
Block
which contains the element at
index
.
|
-
返回
-
Start index of the block. I.e., the requested element can be found within the block at
index
- start index.
◆
GetBlock()
[2/7]
◆
PrivateInsert()
For future compatibility, not implemented at the moment.
◆
Resize()
Resizes the array to contain count elements. If count is smaller than
GetCount()
all extra elements are being deleted. If it is greater the array is expanded and the default constructor is called for new elements.
-
参数
-
[in]
|
count
|
New array size.
|
[in]
|
resizeFlags
|
See COLLECTION_RESIZE_FLAGS.
|
-
返回
-
False if allocation failed.
◆
SetCapacityHint()
Prepare the internal array so that it can hold at least the given number of elements with as few further memory allocations as possible.
-
参数
-
[in]
|
requestedCapacity
|
The desired internal capacity.
|
[in]
|
resizeFlags
|
If ON_GROW_FIT_TO_SIZE is set, the collection will use only as much memory as needed to hold the data.
|
-
返回
-
False if allocation failed.
◆
Insert()
[1/5]
Inserts a new element at
index
. The element will be default-constructed.
-
参数
-
[in]
|
index
|
Insertion index (the array size will increase and the existing elements are moved).
|
-
返回
-
Element reference or OutOfMemoryError if the allocation failed (or position is out of boundaries).
◆
Insert()
[2/5]
Inserts a new element at index position and initializes it with #value.
-
参数
-
[in]
|
index
|
Insert index (the array size will increase and the existing elements are moved).
|
[in]
|
value
|
Value to be inserted.
|
-
返回
-
Element reference or OutOfMemoryError if the allocation failed (or position is out of boundaries).
◆
Insert()
[3/5]
Inserts a new element at index position and initializes it with #value.
-
参数
-
[in]
|
index
|
Insert index (the array size will increase and the existing elements are moved).
|
[in]
|
value
|
Value to be inserted.
|
-
返回
-
Element reference or OutOfMemoryError if the allocation failed (or position is out of boundaries).
◆
Insert()
[4/5]
Inserts a number of new elements at
index
. The elements will be copied.
-
参数
-
[in]
|
index
|
Insertion index (the array size will increase and the existing elements are moved).
|
[in]
|
values
|
Block
with values to be copied. If the block points to nullptr, only its count is used, and you have to call the constructor of the new elements manually.
|
-
返回
-
False if insert failed.
◆
Insert()
[5/5]
Inserts a number of new elements at
index
. The elements will be moved.
-
参数
-
[in]
|
index
|
Insertion index (the array size will increase and the existing elements are moved).
|
[in]
|
values
|
Block
with values to be moved. If the block points to nullptr, only its count is used, and you have to call the constructor of the new elements manually.
|
-
返回
-
False if insert failed.
◆
Append()
[1/4]
Adds a new element at the end of the array. The element will be default-constructed.
-
返回
-
Element reference or OutOfMemoryError if the allocation failed.
◆
Append()
[2/4]
Adds a new element at the end of the array and initializes it with #value.
-
参数
-
[in]
|
value
|
Value to be appended.
|
-
返回
-
Element reference or OutOfMemoryError if the allocation failed.
◆
Append()
[3/4]
Adds a new element at the end of the array and initializes it with #value.
-
参数
-
[in]
|
value
|
Value to be appended.
|
-
返回
-
Element reference or OutOfMemoryError if the allocation failed.
◆
Append()
[4/4]
Adds a new element at the end of the array and initializes it with #value.
-
参数
-
[in]
|
value
|
Value to be appended.
|
-
返回
-
Element reference or OutOfMemoryError if the allocation failed.
◆
Pop()
[1/2]
Deletes the last element.
-
返回
-
True if there was at least one element.
◆
Pop()
[2/2]
Deletes the last element.
-
参数
-
[out]
|
dst
|
Nullptr or pointer to return value.
|
-
返回
-
True if there was at least one element.
◆
Erase()
[1/2]
Erases (removes and deletes) elements.
-
参数
-
[in]
|
index
|
Erase index.
|
[in]
|
count
|
Number of elements to be erased (if eraseCnt is higher than what is available at position
Erase()
will succeed, but remove only the number of available elements).
|
-
返回
-
True if operation was successul.
◆
Erase()
[2/2]
Erases (removes and deletes) an element.
-
参数
-
[in]
|
it
|
Iterator pointing to the element to erase.
|
-
返回
-
True if operation was successul.
◆
SwapErase()
Erases elements within the array and moves elements from the end to the erased gap. This is generally faster than Erase because at most count elements have to be moved, but it changes the order of elements.
-
参数
-
[in]
|
index
|
Erase index.
|
[in]
|
count
|
Number of elements to be erased (if eraseCnt is higher than what is available at position
Erase()
will succeed, but remove only the number of available elements).
|
-
返回
-
True if operation was successul.
◆
Reset()
Deletes all elements (calls destructors and frees memory).
◆
Flush()
Deletes all elements, but doesn't free memory (calls destructors though).
◆
CopyFrom()
Sets this array to a copy of the given other array.
-
参数
-
-
返回
-
Success of operation.
◆
SetPersistentIdGenerator()
MAXON_METHOD
void SetPersistentIdGenerator
|
(
|
const PersistentIdGenerator &
|
generator
|
)
|
|
◆
GetMemorySize()
Calculates the memory usage for this array.
-
返回
-
Memory size in bytes.
◆
HasType()
◆
AssertType()
Issues a failed DebugAssert if the
DataType
of this array doesn't match T. If T is Generic, no check happens.
-
Template Parameters
-
◆
AssertCast()
[1/2]
Casts this array to an array with elements of type T2. If T2 doesn't match the actual data type of this array, a failed DebugAssert is issued. This function only makes sense when the original array uses Generic as its type.
-
Template Parameters
-
T2
|
Element type of the destination array.
|
-
返回
-
This array, cast to an
ArrayInterface
of T2 elements.
◆
AssertCast()
[2/2]
Casts this array to an array with elements of type T2. If T2 doesn't match the actual data type of this array, a failed DebugAssert is issued. This function only makes sense when the original array uses Generic as its type.
-
Template Parameters
-
T2
|
Element type of the destination array.
|
-
返回
-
This array, cast to an
ArrayInterface
of T2 elements.
◆
operator const ArrayInterface< const TYPE > &()
◆
operator const ArrayInterface< typename std::conditional< STD_IS_REPLACEMENT()
◆
operator ArrayInterface< typename std::conditional< STD_IS_REPLACEMENT()
◆
operator const NonConstArray< TYPE > &()
◆
operator const NonConstArray< typename std::conditional< STD_IS_REPLACEMENT()
◆
Begin()
[1/2]
Returns an iterator pointing to the first array element.
-
返回
-
Iterator for the first element (equal to
End()
if the array is empty).
◆
Begin()
[2/2]
Returns an iterator pointing to the first array element.
-
返回
-
Iterator for the first element (equal to
End()
if the array is empty).
◆
End()
[1/2]
Returns an iterator pointing one behind the last array element.
-
返回
-
Iterator for the array end, this is one behind the last element.
◆
End()
[2/2]
Returns an iterator pointing one behind the last array element.
-
返回
-
Iterator for the array end, this is one behind the last element.
◆
Alloc()
◆
GetBlock()
[3/7]
Determines a contiguous, possibly strided block of array elements which contains the element at
index
. The returned blocks are guaranteed to form a partition of the array, i.e., no two blocks overlap, and they cover the whole array.
Using this method can greatly reduce the performance penalty of virtual method invocations of the
Array
interface as only one such invocation has to happen per block, and a block may consist of a relatively large number of elements which can then be accessed directly.
-
参数
-
[in]
|
index
|
Element index.
|
[out]
|
block
|
Block
which contains the element at
index
.
|
-
返回
-
Start index of the block. I.e., the requested element can be found within the block at
index
- start index.
◆
GetBlock()
[4/7]
◆
GetBlock()
[5/7]
◆
GetBlock()
[6/7]
Determines a contiguous, possibly strided writable block of array elements which contains the element at
index
. The returned blocks are guaranteed to form a partition of the array, i.e., no two blocks overlap, and they cover the whole array.
Using this method can greatly reduce the performance penalty of virtual method invocations of the
Array
interface as only one such invocation has to happen per block, and a block may consist of a relatively large number of elements which can then be accessed directly.
-
参数
-
[in]
|
index
|
Element index.
|
[out]
|
block
|
Block
which contains the element at
index
.
|
-
返回
-
Start index of the block. I.e., the requested element can be found within the block at
index
- start index. @MAXON_ANNOTATION{cowName=GetWritableBlock}
◆
GetBlock()
[7/7]
Friends And Related Function Documentation
◆
ArrayImpl
◆
StrongCOWRefHandler
Member Data Documentation
◆
MAXON_METHOD_RESERVE
◆
DummyReturnType
[1/3]
◆
DummyReturnType
[2/3]
const const Generic ::
type
& const DummyReturnType
|
◆
DummyReturnType
[3/3]