52 #ifndef __PCL_IndirectArray_h
53 #define __PCL_IndirectArray_h
58 #include <pcl/Diagnostics.h>
90 template <
class T,
class A = StandardAllocator>
153 m_array.Append( (
void*)
nullptr, n );
161 m_array.Append( (
void*)p, n );
201 return m_array.IsUnique();
213 return m_array.IsAliasOf( x.m_array );
226 m_array.EnsureUnique();
235 return m_array.Size();
243 return m_array.Length();
253 return m_array.Capacity();
265 return m_array.Available();
285 return m_array.IsValid();
293 return m_array.IsEmpty();
302 return m_array.LowerBound();
311 return m_array.UpperBound();
327 m_array.SetAllocator( a );
367 return (T*&)m_array[i];
376 return (
const T*)m_array[i];
384 return (T*&)*Begin();
519 return IsEmpty() ? nullptr : *Begin();
526 const T* First()
const
528 return IsEmpty() ? nullptr : *Begin();
537 return IsEmpty() ? nullptr : *ReverseBegin();
544 const T* Last()
const
546 return IsEmpty() ? nullptr : *ReverseBegin();
576 #ifndef __PCL_NO_STL_COMPATIBLE_ITERATORS
633 m_array.Assign( x.m_array );
656 m_array.Transfer( x.m_array );
670 m_array.Transfer( x.m_array );
679 m_array.Assign( (
void*)p, n );
691 m_array.Assign( i, j );
708 PCL_ASSERT_CONTAINER( C, T );
709 CloneObjects( x, (C*)
nullptr );
736 return iterator( m_array.Release() );
765 return Grow( ConstEnd(), n );
856 m_array.Append( x.m_array );
865 m_array.Append( (
void*)p, n );
877 m_array.Append( p, q );
886 m_array.Prepend( x.m_array );
895 m_array.Prepend( (
void*)p, n );
907 m_array.Prepend( p, q );
984 m_array.RemoveFirst( n );
1001 m_array.RemoveLast( n );
1033 if ( *i ==
nullptr || **i != v )
1035 if ( r.
Length() < m_array.Length() )
1036 m_array.Transfer( r );
1051 if ( *i ==
nullptr || !p( **i, v ) )
1053 if ( r.
Length() < m_array.Length() )
1054 m_array.Transfer( r );
1065 m_array.Remove( (
void*)p );
1125 if ( i < ConstEnd() )
1130 for ( ; i < j; ++i )
1131 if ( *i !=
nullptr )
1132 DeleteObject( i, a );
1151 for (
iterator i =
const_cast<iterator>( ConstBegin() ); i < ConstEnd(); ++i )
1152 if ( *i !=
nullptr && **i == v )
1153 DeleteObject( i, a );
1172 for (
iterator i =
const_cast<iterator>( ConstBegin() ); i < ConstEnd(); ++i )
1173 if ( *i !=
nullptr && p( **i, v ) )
1174 DeleteObject( i, a );
1189 for (
iterator i =
const_cast<iterator>( ConstBegin() ); i < ConstEnd(); ++i )
1190 if ( *i !=
nullptr )
1191 DeleteObject( i, a );
1244 for (
iterator i =
const_cast<iterator>( ConstBegin() ); i < ConstEnd(); ++i )
1245 if ( *i !=
nullptr && **i == v )
1246 DeleteObject( i, a );
1250 if ( r.
Length() < m_array.Length() )
1251 m_array.Transfer( r );
1270 for (
iterator i =
const_cast<iterator>( ConstBegin() ); i < ConstEnd(); ++i )
1271 if ( *i !=
nullptr && p( **i, v ) )
1272 DeleteObject( i, a );
1276 if ( r.
Length() < m_array.Length() )
1277 m_array.Transfer( r );
1298 m_array.Remove( (
void*)
nullptr );
1371 m_array.Reserve( n );
1396 Apply( [v]( T* x ){ *x = v; } );
1478 return m_array.Count( (
void*)p );
1574 m_array.Rotate( n );
1581 m_array.ShiftLeft( (
void*)p, n );
1588 m_array.ShiftRight( (
void*)p, n );
1616 return iterator( m_array.Search( (
void*)p ) );
1660 return iterator( m_array.SearchLast( (
void*)p ) );
1697 template <
class FI,
class BP>
1705 template <
class FI,
class BP>
1729 template <
class C,
class BP>
1737 template <
class C,
class BP>
1761 template <
class BI,
class BP>
1769 template <
class BI,
class BP>
1793 template <
class C,
class BP>
1801 template <
class C,
class BP>
1811 return Search( v ) != End();
1818 return m_array.Contains( (
void*)p );
1826 return Search( v, p ) != End();
1834 return SearchSubset( i, j ) != End();
1839 template <
class FI,
class BP>
1842 return SearchSubset( i, j, p ) != End();
1850 return SearchSubset( c ) != End();
1855 template <
class C,
class BP>
1858 return SearchSubset( c, p ) != End();
1900 template <
class S,
typename SP>
1901 S& ToSeparated( S& s, SP separator )
const
1906 while ( *i ==
nullptr )
1909 s.Append( S( **i ) );
1912 if ( *i !=
nullptr )
1914 s.Append( separator );
1915 s.Append( S( **i ) );
1917 while ( ++i < End() );
1944 template <
class S,
typename SP,
class AF>
1945 S& ToSeparated( S& s, SP separator, AF append )
const
1950 while ( *i ==
nullptr )
1953 append( s, S( **i ) );
1958 if ( *i !=
nullptr )
1961 append( s, S( **i ) );
1963 while ( ++i < End() );
1978 S& ToCommaSeparated( S& s )
const
1980 return ToSeparated( s,
',' );
1992 S& ToSpaceSeparated( S& s )
const
1994 return ToSeparated( s,
' ' );
2006 S& ToTabSeparated( S& s )
const
2008 return ToSeparated( s,
'\t' );
2020 S& ToNewLineSeparated( S& s )
const
2022 return ToSeparated( s,
'\n' );
2037 return m_array.Hash64( seed );
2052 return m_array.Hash32( seed );
2068 array_implementation m_array;
2070 void DeleteObject( iterator i, allocator& a )
2078 void CloneObjects(
const C& x, DirectContainer<T>* )
2081 Reserve( x.Length() );
2082 Append(
static_cast<T*
>(
nullptr ), x.Length() );
2083 iterator i = Begin(), j = End();
2084 typename C::const_iterator p = x.Begin(), q = x.End();
2085 for ( allocator a; i < j && p != q; ++i, ++p )
2087 *i = a.Allocate( 1 );
2093 void CloneObjects(
const C& x, IndirectContainer<T>* )
2096 Reserve( x.Length() );
2097 Append(
static_cast<T*
>(
nullptr ), x.Length() );
2098 iterator i = Begin(), j = End();
2099 typename C::const_iterator p = x.Begin(), q = x.End();
2100 for ( allocator a; i < j && p != q; ++i, ++p )
2101 if ( *p !=
nullptr )
2103 *i = a.Allocate( 1 );
2117 template <
class T,
class A>
inline
2129 template <
class T,
class A>
inline
2142 template <
class T,
class A,
class V>
inline
2143 IndirectArray<T,A>&
operator <<( IndirectArray<T,A>& x,
const V* p )
2145 x.Append(
static_cast<const T*
>( p ) );
2156 template <
class T,
class A,
class V>
inline
2157 IndirectArray<T,A>&
operator <<( IndirectArray<T,A>&& x,
const V* p )
2159 x.Append(
static_cast<const T*
>( p ) );
2168 template <
class T,
class A>
inline
2169 IndirectArray<T,A>&
operator <<( IndirectArray<T,A>& x1,
const IndirectArray<T,A>& x2 )
2180 template <
class T,
class A>
inline
2181 IndirectArray<T,A>&
operator <<( IndirectArray<T,A>&& x1,
const IndirectArray<T,A>& x2 )
Provides memory allocation for PCL containers.
size_type Length() const noexcept
Generic dynamic array of pointers to objects.
const_iterator LastThat(F f) const
void Destroy(iterator i, size_type n=1)
size_type UpperBound() const
void Assign(const T *p, size_type n=1)
const_iterator SearchSubset(const C &c) const
void Transfer(IndirectArray &x)
reverse_iterator ReverseEnd()
void Add(const IndirectArray &x)
iterator SearchLastSubset(const C &c, BP p)
void Truncate(const_iterator i)
T *const * const_iterator
IndirectArray(size_type n, const T *p)
iterator SearchSubset(FI i, FI j, BP p)
const_iterator ConstBegin() const
void Delete(const T &v, BP p)
IndirectArray(FI i, FI j)
iterator Replace(const_iterator i, const_iterator j, FI p, FI q)
const_iterator SearchLastSubset(const C &c) const
void UniquifyIterators(iterator &i, iterator &j)
iterator SearchLastSubset(BI i, BI j, BP p)
void Reserve(size_type n)
const_iterator MinItem() const
const allocator & Allocator() const
iterator ContainsSubset(FI i, FI j) const
friend void Swap(IndirectArray &x1, IndirectArray &x2)
bool Contains(const T &v, BP p) const
IndirectArray(IndirectArray &&)=default
typename array_implementation::const_iterator const_array_iterator
const_iterator ConstEnd() const
size_type Available() const
iterator Expand(size_type n=1)
void Remove(const T &v, BP p)
const_iterator SearchSubset(FI i, FI j) const
const_iterator SearchLastSubset(const C &c, BP p) const
uint32 Hash32(uint32 seed=0) const
iterator SearchLast(const T *p)
iterator ContainsSubset(const C &c) const
void Remove(const_iterator i, const_iterator j)
void Destroy(const T &v, BP p)
void ShiftRight(const T *p, size_type n=1)
void UniquifyIterator(iterator &i)
iterator Insert(const_iterator i, FI p, FI q)
void SetAllocator(const allocator &a)
const_reverse_iterator ReverseBegin() const
const_iterator Search(const T &v) const
bool Contains(const T *p) const
const_iterator Search(const T *p) const
size_type Count(const T &v, BP p) const
reverse_iterator ReverseBegin()
const_iterator Search(const T &v, BP p) const
iterator Search(const T &v)
const_iterator FirstThat(F f) const
const_iterator SearchLastSubset(BI i, BI j, BP p) const
const_iterator SearchSubset(FI i, FI j, BP p) const
void Destroy(iterator i, iterator j)
const_iterator At(size_type i) const
void Delete(iterator i, size_type n=1)
iterator Grow(const_iterator i, size_type n=1)
iterator SearchLastSubset(const C &c)
iterator SearchSubset(const C &c, BP p)
uint64 Hash64(uint64 seed=0) const
size_type CountIf(UP p) const
size_type Capacity() const
const_reverse_iterator ConstReverseBegin() const
const_iterator SearchLast(const T &v) const
void Rotate(distance_type n)
void Assign(const IndirectArray &x)
const_iterator MinItem(BP p) const
bool IsAliasOf(const IndirectArray &x) const
const_iterator MaxItem(BP p) const
bool Contains(const T &v) const
void Transfer(IndirectArray &&x)
const_reverse_iterator ReverseEnd() const
iterator Replace(const_iterator i, const_iterator j, const IndirectArray &x)
const_iterator SearchLast(const T &v, BP p) const
void Append(const T *p, size_type n=1)
const_iterator MaxItem() const
size_type LowerBound() const
iterator SearchLast(const T &v)
void Add(const T *p, size_type n=1)
IndirectArray(const IndirectArray &)=default
void Prepend(const IndirectArray &x)
void Import(iterator i, iterator j)
const_iterator SearchLastSubset(BI i, BI j) const
void ShiftLeft(const T *p, size_type n=1)
const_iterator begin() const
iterator SearchSubset(FI i, FI j)
iterator ContainsSubset(const C &c, BP p) const
iterator Insert(const_iterator i, const T *p, size_type n=1)
const_iterator end() const
uint64 Hash(uint64 seed=0) const
void Remove(const_iterator i, size_type n=1)
iterator ContainsSubset(FI i, FI j, BP p) const
void RemoveLast(size_type n=1)
IndirectArray(size_type n)
iterator Insert(const_iterator i, const IndirectArray &x)
void Shrink(size_type n=1)
const_iterator Begin() const
const_iterator End() const
iterator SearchSubset(const C &c)
typename array_implementation::iterator array_iterator
void Append(const IndirectArray &x)
iterator SearchLast(const T &v, BP p)
size_type Count(const T &v) const
const_iterator SearchLast(const T *p) const
iterator SearchLastSubset(BI i, BI j)
iterator Search(const T &v, BP p)
void Prepend(const T *p, size_type n=1)
void RemoveFirst(size_type n=1)
iterator MutableIterator(const_iterator i)
iterator Replace(const_iterator i, const_iterator j, const T *p, size_type n=1)
const_iterator SearchSubset(const C &c, BP p) const
iterator Search(const T *p)
void CloneAssign(const C &x)
const_reverse_iterator ConstReverseEnd() const
size_type Count(const T *p) const
void Delete(iterator i, iterator j)
A wrapper class that applies a binary predicate to pointers to objects.
Root base class of all PCL containers of pointers to objects.
A wrapper class that applies a unary function to pointers to objects.
A wrapper class that applies a unary predicate to pointers to objects.
Reverse random access iterator.
Array< T, A > & operator<<(Array< T, A > &x, const V &v)
bool operator==(const Array< T, A > &x1, const Array< T, A > &x2) noexcept
bool operator<(const Array< T, A > &x1, const Array< T, A > &x2) noexcept
Complex< T1 > operator*(const Complex< T1 > &c1, const Complex< T2 > &c2) noexcept
uint64 Hash64(const void *data, size_type size, uint64 seed=0) noexcept
void Construct(T *p, A &a)
void Swap(GenericPoint< T > &p1, GenericPoint< T > &p2) noexcept
unsigned long long uint64
FI LinearSearch(FI i, FI j, const T &v) noexcept
BI1 SearchLast(BI1 i1, BI1 j1, FI2 i2, FI2 j2) noexcept
BI LinearSearchLast(BI i, BI j, const T &v) noexcept
FI1 Search(FI1 i1, FI1 j1, FI2 i2, FI2 j2) noexcept
void QuickSort(RI i, RI j)
size_type CountIf(FI i, FI j, UP p) noexcept(noexcept(p))
constexpr const T & Min(const T &a, const T &b) noexcept
BI LastThat(BI i, BI j, UP p) noexcept(noexcept(p))
size_type Count(FI i, FI j, const T &v) noexcept
FI MinItem(FI i, FI j) noexcept
bool Equal(FI1 i1, FI2 i2, FI2 j2) noexcept
int Compare(FI1 i1, FI1 j1, FI2 i2, FI2 j2) noexcept
constexpr const T & Max(const T &a, const T &b) noexcept
FI MaxItem(FI i, FI j) noexcept
void Apply(FI i, FI j, F f) noexcept(noexcept(f))
FI FirstThat(FI i, FI j, UP p) noexcept(noexcept(p))
A functional class that tests two pointers for equality of the pointed objects.
A functional class that applies the less than relational operator to the objects pointed to by two po...