50 inline explicit ArrayBase (
const T& item);
59 inline const T*
getPtr (S idx = 0)
const;
60 inline T*
getPtr (S idx = 0);
66 inline const T&
get (S idx)
const;
67 inline T&
get (S idx);
68 inline T
set (S idx,
const T& item);
69 inline const T&
getFirst (
void)
const;
71 inline const T&
getLast (
void)
const;
73 inline void getRange (S start, S end, T* ptr)
const;
75 inline void setRange (S start, S end,
const T* ptr);
80 inline void reset (S size = 0);
83 inline void set (
const T* ptr, S size);
88 inline void clear (
void);
89 inline void resize (S size);
90 inline void reserve (S numElements);
95 inline T&
add (
const T& item);
96 inline T*
add (
const T* ptr, S size);
99 inline T&
insert (S idx,
const T& item);
100 inline T*
insert (S idx,
const T* ptr, S size);
105 inline T
remove (S idx);
106 inline void remove (S start, S end);
110 inline T*
replace (S start, S end, S size);
111 inline T*
replace (S start, S end,
const T* ptr, S size);
116 inline S
indexOf (
const T& item, S fromIdx = 0)
const;
118 inline S
lastIndexOf (
const T& item, S fromIdx)
const;
119 inline bool contains (
const T& item)
const;
132 static inline void copy (T* dst,
const T* src, S size);
133 static inline void copyOverlap (T* dst,
const T* src, S size);
138 inline void init (
void);
139 void realloc (S size);
140 void reallocRound(S size);
227 return getSize() * getStride();
274 return get(getSize() - 1);
281 return get(getSize() - 1);
289 copy(ptr, getPtr(start), end - start);
305 copy(getPtr(start), ptr, end - start);
328 S c =
max(numElements, m_size);
346 copy(getPtr(), ptr, size);
378 if (numElements > m_alloc)
386 return *add(
NULL, 1);
393 T* slot = add(
NULL, 1);
402 S oldSize = getSize();
403 resize(oldSize + size);
404 T* slot = getPtr(oldSize);
406 copy(slot, ptr, size);
414 return replace(getSize(), getSize(), other);
421 return *replace(idx, idx, 1);
428 T* slot = replace(idx, idx, 1);
437 return replace(idx, idx, ptr, size);
444 return replace(idx, idx, other);
452 replace(idx, idx + 1, 0);
460 replace(start, end, 0);
469 return m_ptr[m_size];
481 m_ptr[idx] = m_ptr[m_size];
494 m_size += start - end;
496 S copyStart =
max(m_size, end);
497 copy(m_ptr + start, m_ptr + copyStart, oldSize - copyStart);
509 S tailSize = m_size - end;
510 S newEnd = start +
size;
511 resize(m_size + newEnd - end);
513 copyOverlap(m_ptr + newEnd, m_ptr + end, tailSize);
514 return m_ptr + start;
521 T* slot = replace(start, end, size);
523 copy(slot, ptr, size);
538 return replace(start, end, ptr, other.
getSize());
545 for (S i =
max(fromIdx, 0); i < getSize(); i++)
555 return lastIndexOf(item, getSize() - 1);
562 for (S i =
min(fromIdx, getSize() - 1); i >= 0; i--)
572 return (indexOf(item) != -1);
579 S idx = indexOf(item);
612 if (getSize() != other.
getSize())
615 for (S i = 0; i < getSize(); i++)
616 if (
get(i) != other[i])
625 return (!
operator==(other));
637 for (S i = 0; i <
size; i++)
650 if (dst < src || dst >= src + size)
651 for (S i = 0; i <
size; i++)
654 for (S i = size - 1; i >= 0; i--)
676 newPtr =
new T[
size];
677 copy(newPtr, m_ptr,
min(size, m_size));
687 template <
class T,
typename S>
void ArrayBase<T,S>::reallocRound(S size)
690 S rounded =
max((S)(MinBytes /
sizeof(T)), S(1));
691 while (size > rounded)
700 inline void ArrayBase<S16,S32>::copy(
S16* dst,
const S16* src,
int size) { memcpy(dst, src, size *
sizeof(
S16)); }
701 inline void ArrayBase<U16,S32>::copy(
U16* dst,
const U16* src,
int size) { memcpy(dst, src, size *
sizeof(
U16)); }
705 inline void ArrayBase<S64,S32>::copy(
S64* dst,
const S64* src,
int size) { memcpy(dst, src, size *
sizeof(
S64)); }
706 inline void ArrayBase<U64,S32>::copy(
U64* dst,
const U64* src,
int size) { memcpy(dst, src, size *
sizeof(
U64)); }
707 inline void ArrayBase<F64,S32>::copy(
F64* dst,
const F64* src,
int size) { memcpy(dst, src, size *
sizeof(
F64)); }
709 inline void ArrayBase<Vec2i,S32>::copy(Vec2i* dst,
const Vec2i* src,
int size) { memcpy(dst, src, size *
sizeof(Vec2i)); }
710 inline void ArrayBase<Vec2f,S32>::copy(Vec2f* dst,
const Vec2f* src,
int size) { memcpy(dst, src, size *
sizeof(Vec2f)); }
711 inline void ArrayBase<Vec3i,S32>::copy(Vec3i* dst,
const Vec3i* src,
int size) { memcpy(dst, src, size *
sizeof(Vec3i)); }
712 inline void ArrayBase<Vec3f,S32>::copy(Vec3f* dst,
const Vec3f* src,
int size) { memcpy(dst, src, size *
sizeof(Vec3f)); }
713 inline void ArrayBase<Vec4i,S32>::copy(Vec4i* dst,
const Vec4i* src,
int size) { memcpy(dst, src, size *
sizeof(Vec4i)); }
714 inline void ArrayBase<Vec4f,S32>::copy(Vec4f* dst,
const Vec4f* src,
int size) { memcpy(dst, src, size *
sizeof(Vec4f)); }
716 inline void ArrayBase<Mat2f,S32>::copy(Mat2f* dst,
const Mat2f* src,
int size) { memcpy(dst, src, size *
sizeof(Mat2f)); }
717 inline void ArrayBase<Mat3f,S32>::copy(Mat3f* dst,
const Mat3f* src,
int size) { memcpy(dst, src, size *
sizeof(Mat3f)); }
718 inline void ArrayBase<Mat4f,S32>::copy(Mat4f* dst,
const Mat4f* src,
int size) { memcpy(dst, src, size *
sizeof(Mat4f)); }
722 inline void ArrayBase<S8,S64>::copy(
S8* dst,
const S8* src,
S64 size) { memcpy(dst, src, (
size_t)size *
sizeof(
S8)); }
723 inline void ArrayBase<U8,S64>::copy(
U8* dst,
const U8* src,
S64 size) { memcpy(dst, src, (
size_t)size *
sizeof(
U8)); }
724 inline void ArrayBase<S16,S64>::copy(
S16* dst,
const S16* src,
S64 size) { memcpy(dst, src, (
size_t)size *
sizeof(
S16)); }
725 inline void ArrayBase<U16,S64>::copy(
U16* dst,
const U16* src,
S64 size) { memcpy(dst, src, (
size_t)size *
sizeof(
U16)); }
726 inline void ArrayBase<S32,S64>::copy(
S32* dst,
const S32* src,
S64 size) { memcpy(dst, src, (
size_t)size *
sizeof(
S32)); }
727 inline void ArrayBase<U32,S64>::copy(
U32* dst,
const U32* src,
S64 size) { memcpy(dst, src, (
size_t)size *
sizeof(
U32)); }
728 inline void ArrayBase<F32,S64>::copy(
F32* dst,
const F32* src,
S64 size) { memcpy(dst, src, (
size_t)size *
sizeof(
F32)); }
729 inline void ArrayBase<S64,S64>::copy(
S64* dst,
const S64* src,
S64 size) { memcpy(dst, src, (
size_t)size *
sizeof(
S64)); }
730 inline void ArrayBase<U64,S64>::copy(
U64* dst,
const U64* src,
S64 size) { memcpy(dst, src, (
size_t)size *
sizeof(
U64)); }
731 inline void ArrayBase<F64,S64>::copy(
F64* dst,
const F64* src,
S64 size) { memcpy(dst, src, (
size_t)size *
sizeof(
F64)); }
733 inline void ArrayBase<Vec2i,S64>::copy(Vec2i* dst,
const Vec2i* src,
S64 size) { memcpy(dst, src, (
size_t)size *
sizeof(Vec2i)); }
734 inline void ArrayBase<Vec2f,S64>::copy(Vec2f* dst,
const Vec2f* src,
S64 size) { memcpy(dst, src, (
size_t)size *
sizeof(Vec2f)); }
735 inline void ArrayBase<Vec3i,S64>::copy(Vec3i* dst,
const Vec3i* src,
S64 size) { memcpy(dst, src, (
size_t)size *
sizeof(Vec3i)); }
736 inline void ArrayBase<Vec3f,S64>::copy(Vec3f* dst,
const Vec3f* src,
S64 size) { memcpy(dst, src, (
size_t)size *
sizeof(Vec3f)); }
737 inline void ArrayBase<Vec4i,S64>::copy(Vec4i* dst,
const Vec4i* src,
S64 size) { memcpy(dst, src, (
size_t)size *
sizeof(Vec4i)); }
738 inline void ArrayBase<Vec4f,S64>::copy(Vec4f* dst,
const Vec4f* src,
S64 size) { memcpy(dst, src, (
size_t)size *
sizeof(Vec4f)); }
740 inline void ArrayBase<Mat2f,S64>::copy(Mat2f* dst,
const Mat2f* src,
S64 size) { memcpy(dst, src, (
size_t)size *
sizeof(Mat2f)); }
741 inline void ArrayBase<Mat3f,S64>::copy(Mat3f* dst,
const Mat3f* src,
S64 size) { memcpy(dst, src, (
size_t)size *
sizeof(Mat3f)); }
742 inline void ArrayBase<Mat4f,S64>::copy(Mat4f* dst,
const Mat4f* src,
S64 size) { memcpy(dst, src, (
size_t)size *
sizeof(Mat4f)); }
const T & getFirst(void) const
static void copy(T *dst, const T *src, S size)
Array64(const T *ptr, S64 size)
S getNumBytes(void) const
const T & operator[](S idx) const
const T & get(S idx) const
const T & getLast(void) const
T * replace(S start, S end, S size)
bool removeItem(const T &item)
static void copyOverlap(T *dst, const T *src, S size)
FW_CUDA_FUNC T min(const VectorBase< T, L, S > &v)
FW_CUDA_FUNC T max(const VectorBase< T, L, S > &v)
Array64(const Array64< T > &other)
void * realloc(void *ptr, size_t size)
S getCapacity(void) const
ArrayBase< T, S > & operator=(const ArrayBase< T, S > &other)
void setCapacity(S numElements)
void reserve(S numElements)
Array(const T *ptr, S32 size)
bool operator==(const ArrayBase< T, S > &other) const
S lastIndexOf(const T &item) const
void getRange(S start, S end, T *ptr) const
T set(S idx, const T &item)
const T * getPtr(S idx=0) const
Array(const Array< T > &other)
CUdevice int ordinal char int CUdevice dev CUdevprop CUdevice dev CUcontext ctx CUcontext ctx CUcontext pctx CUmodule const void image CUmodule const void fatCubin CUfunction CUmodule const char name void p CUfunction unsigned int bytes CUtexref pTexRef CUtexref CUarray unsigned int Flags CUtexref int CUaddress_mode am CUtexref unsigned int Flags CUaddress_mode CUtexref int dim CUarray_format int CUtexref hTexRef CUfunction unsigned int numbytes CUfunction int float value CUfunction int CUtexref hTexRef CUfunction int int grid_height CUevent unsigned int Flags CUevent hEvent CUevent hEvent CUstream unsigned int Flags CUstream hStream GLuint bufferobj unsigned int CUdevice dev CUdeviceptr unsigned int CUmodule const char name CUdeviceptr unsigned int bytesize CUdeviceptr dptr void unsigned int bytesize void CUdeviceptr unsigned int ByteCount CUarray unsigned int CUdeviceptr unsigned int ByteCount CUarray unsigned int const void unsigned int ByteCount CUarray unsigned int CUarray unsigned int unsigned int ByteCount void CUarray unsigned int unsigned int CUstream hStream const CUDA_MEMCPY2D pCopy CUdeviceptr const void unsigned int CUstream hStream const CUDA_MEMCPY2D CUstream hStream CUdeviceptr unsigned char unsigned int N CUdeviceptr unsigned int unsigned int N CUdeviceptr unsigned int unsigned short unsigned int unsigned int Height CUarray const CUDA_ARRAY_DESCRIPTOR pAllocateArray CUarray const CUDA_ARRAY3D_DESCRIPTOR pAllocateArray unsigned int CUtexref CUdeviceptr unsigned int bytes CUcontext unsigned int CUdevice device GLenum texture GLenum GLuint buffer GLenum GLuint renderbuffer GLenum GLsizeiptr size
bool operator!=(const ArrayBase< T, S > &other) const
S indexOf(const T &item, S fromIdx=0) const
void setRange(S start, S end, const T *ptr)
bool contains(const T &item) const