52 #ifndef __PCL_IndirectArray_h
53 #define __PCL_IndirectArray_h
58 #include <pcl/Diagnostics.h>
90 template <
class T,
class A = StandardAllocator>
165 m_array.Append( (
void*)
nullptr, n );
173 m_array.Append( (
void*)p, n );
213 return m_array.IsUnique();
225 return m_array.IsAliasOf( x.m_array );
238 m_array.EnsureUnique();
247 return m_array.Size();
255 return m_array.Length();
265 return m_array.Capacity();
277 return m_array.Available();
297 return m_array.IsValid();
305 return m_array.IsEmpty();
314 return m_array.LowerBound();
323 return m_array.UpperBound();
339 m_array.SetAllocator( a );
379 return (T*&)m_array[i];
388 return (
const T*)m_array[i];
396 return (T*&)*Begin();
531 return IsEmpty() ? nullptr : *Begin();
538 const T* First()
const
540 return IsEmpty() ? nullptr : *Begin();
549 return IsEmpty() ? nullptr : *ReverseBegin();
556 const T* Last()
const
558 return IsEmpty() ? nullptr : *ReverseBegin();
588 #ifndef __PCL_NO_STL_COMPATIBLE_ITERATORS
645 m_array.Assign( x.m_array );
668 m_array.Transfer( x.m_array );
682 m_array.Transfer( x.m_array );
691 m_array.Assign( (
void*)p, n );
703 m_array.Assign( i, j );
720 PCL_ASSERT_CONTAINER( C, T );
721 CloneObjects( x, (C*)
nullptr );
748 return iterator( m_array.Release() );
777 return Grow( ConstEnd(), n );
868 m_array.Append( x.m_array );
877 m_array.Append( (
void*)p, n );
889 m_array.Append( p, q );
898 m_array.Prepend( x.m_array );
907 m_array.Prepend( (
void*)p, n );
919 m_array.Prepend( p, q );
996 m_array.RemoveFirst( n );
1013 m_array.RemoveLast( n );
1045 if ( *i ==
nullptr || **i != v )
1047 if ( r.
Length() < m_array.Length() )
1048 m_array.Transfer( r );
1063 if ( *i ==
nullptr || !p( **i, v ) )
1065 if ( r.
Length() < m_array.Length() )
1066 m_array.Transfer( r );
1077 m_array.Remove( (
void*)p );
1137 if ( i < ConstEnd() )
1142 for ( ; i < j; ++i )
1143 if ( *i !=
nullptr )
1144 DeleteObject( i, a );
1163 for (
iterator i =
const_cast<iterator>( ConstBegin() ); i < ConstEnd(); ++i )
1164 if ( *i !=
nullptr && **i == v )
1165 DeleteObject( i, a );
1184 for (
iterator i =
const_cast<iterator>( ConstBegin() ); i < ConstEnd(); ++i )
1185 if ( *i !=
nullptr && p( **i, v ) )
1186 DeleteObject( i, a );
1201 for (
iterator i =
const_cast<iterator>( ConstBegin() ); i < ConstEnd(); ++i )
1202 if ( *i !=
nullptr )
1203 DeleteObject( i, a );
1256 for (
iterator i =
const_cast<iterator>( ConstBegin() ); i < ConstEnd(); ++i )
1257 if ( *i !=
nullptr && **i == v )
1258 DeleteObject( i, a );
1262 if ( r.
Length() < m_array.Length() )
1263 m_array.Transfer( r );
1282 for (
iterator i =
const_cast<iterator>( ConstBegin() ); i < ConstEnd(); ++i )
1283 if ( *i !=
nullptr && p( **i, v ) )
1284 DeleteObject( i, a );
1288 if ( r.
Length() < m_array.Length() )
1289 m_array.Transfer( r );
1310 m_array.Remove( (
void*)
nullptr );
1383 m_array.Reserve( n );
1408 Apply( [v]( T* x ){ *x = v; } );
1490 return m_array.Count( (
void*)p );
1586 m_array.Rotate( n );
1593 m_array.ShiftLeft( (
void*)p, n );
1600 m_array.ShiftRight( (
void*)p, n );
1628 return iterator( m_array.Search( (
void*)p ) );
1672 return iterator( m_array.SearchLast( (
void*)p ) );
1709 template <
class FI,
class BP>
1717 template <
class FI,
class BP>
1741 template <
class C,
class BP>
1749 template <
class C,
class BP>
1773 template <
class BI,
class BP>
1781 template <
class BI,
class BP>
1805 template <
class C,
class BP>
1813 template <
class C,
class BP>
1823 return Search( v ) != End();
1830 return m_array.Contains( (
void*)p );
1838 return Search( v, p ) != End();
1846 return SearchSubset( i, j ) != End();
1851 template <
class FI,
class BP>
1854 return SearchSubset( i, j, p ) != End();
1862 return SearchSubset( c ) != End();
1867 template <
class C,
class BP>
1870 return SearchSubset( c, p ) != End();
1912 template <
class S,
typename SP>
1913 S& ToSeparated( S& s, SP separator )
const
1918 while ( *i ==
nullptr )
1921 s.Append( S( **i ) );
1924 if ( *i !=
nullptr )
1926 s.Append( separator );
1927 s.Append( S( **i ) );
1929 while ( ++i < End() );
1956 template <
class S,
typename SP,
class AF>
1957 S& ToSeparated( S& s, SP separator, AF append )
const
1962 while ( *i ==
nullptr )
1965 append( s, S( **i ) );
1970 if ( *i !=
nullptr )
1973 append( s, S( **i ) );
1975 while ( ++i < End() );
1990 S& ToCommaSeparated( S& s )
const
1992 return ToSeparated( s,
',' );
2004 S& ToSpaceSeparated( S& s )
const
2006 return ToSeparated( s,
' ' );
2018 S& ToTabSeparated( S& s )
const
2020 return ToSeparated( s,
'\t' );
2032 S& ToNewLineSeparated( S& s )
const
2034 return ToSeparated( s,
'\n' );
2049 return m_array.Hash64( seed );
2064 return m_array.Hash32( seed );
2080 array_implementation m_array;
2082 void DeleteObject( iterator i, allocator& a )
2090 void CloneObjects(
const C& x, DirectContainer<T>* )
2093 Reserve( x.Length() );
2094 Append(
static_cast<T*
>(
nullptr ), x.Length() );
2095 iterator i = Begin(), j = End();
2096 typename C::const_iterator p = x.Begin(), q = x.End();
2097 for ( allocator a; i < j && p != q; ++i, ++p )
2099 *i = a.Allocate( 1 );
2105 void CloneObjects(
const C& x, IndirectContainer<T>* )
2108 Reserve( x.Length() );
2109 Append(
static_cast<T*
>(
nullptr ), x.Length() );
2110 iterator i = Begin(), j = End();
2111 typename C::const_iterator p = x.Begin(), q = x.End();
2112 for ( allocator a; i < j && p != q; ++i, ++p )
2113 if ( *p !=
nullptr )
2115 *i = a.Allocate( 1 );
2129 template <
class T,
class A>
inline
2141 template <
class T,
class A>
inline
2154 template <
class T,
class A,
class V>
inline
2155 IndirectArray<T,A>&
operator <<( IndirectArray<T,A>& x,
const V* p )
2157 x.Append(
static_cast<const T*
>( p ) );
2168 template <
class T,
class A,
class V>
inline
2169 IndirectArray<T,A>&
operator <<( IndirectArray<T,A>&& x,
const V* p )
2171 x.Append(
static_cast<const T*
>( p ) );
2180 template <
class T,
class A>
inline
2181 IndirectArray<T,A>&
operator <<( IndirectArray<T,A>& x1,
const IndirectArray<T,A>& x2 )
2192 template <
class T,
class A>
inline
2193 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.
const T * const_item_type
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...