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 );
783 Truncate( ConstEnd() - n );
867 m_array.Append( x.m_array );
876 m_array.Append( (
void*)p, n );
888 m_array.Append( p, q );
897 m_array.Prepend( x.m_array );
906 m_array.Prepend( (
void*)p, n );
918 m_array.Prepend( p, q );
1010 if ( *i ==
nullptr || **i != v )
1012 if ( r.
Length() < m_array.Length() )
1013 m_array.Transfer( r );
1028 if ( *i ==
nullptr || !p( **i, v ) )
1030 if ( r.
Length() < m_array.Length() )
1031 m_array.Transfer( r );
1042 m_array.Remove( (
void*)p );
1102 if ( i < ConstEnd() )
1107 for ( ; i < j; ++i )
1108 if ( *i !=
nullptr )
1109 DeleteObject( i, a );
1128 for (
iterator i =
const_cast<iterator>( ConstBegin() ); i < ConstEnd(); ++i )
1129 if ( *i !=
nullptr && **i == v )
1130 DeleteObject( i, a );
1149 for (
iterator i =
const_cast<iterator>( ConstBegin() ); i < ConstEnd(); ++i )
1150 if ( *i !=
nullptr && p( **i, v ) )
1151 DeleteObject( i, a );
1166 for (
iterator i =
const_cast<iterator>( ConstBegin() ); i < ConstEnd(); ++i )
1167 if ( *i !=
nullptr )
1168 DeleteObject( i, a );
1221 for (
iterator i =
const_cast<iterator>( ConstBegin() ); i < ConstEnd(); ++i )
1222 if ( *i !=
nullptr && **i == v )
1223 DeleteObject( i, a );
1227 if ( r.
Length() < m_array.Length() )
1228 m_array.Transfer( r );
1247 for (
iterator i =
const_cast<iterator>( ConstBegin() ); i < ConstEnd(); ++i )
1248 if ( *i !=
nullptr && p( **i, v ) )
1249 DeleteObject( i, a );
1253 if ( r.
Length() < m_array.Length() )
1254 m_array.Transfer( r );
1275 m_array.Remove( (
void*)
nullptr );
1348 m_array.Reserve( n );
1373 Apply( [v]( T* x ){ *x = v; } );
1433 return m_array.Count( (
void*)p );
1501 m_array.Rotate( n );
1508 m_array.ShiftLeft( (
void*)p, n );
1515 m_array.ShiftRight( (
void*)p, n );
1529 return iterator( m_array.Search( (
void*)p ) );
1552 return iterator( m_array.SearchLast( (
void*)p ) );
1574 template <
class FI,
class BP>
1591 template <
class C,
class BP>
1608 template <
class BI,
class BP>
1625 template <
class C,
class BP>
1636 return Search( v ) != End();
1643 return m_array.Contains( (
void*)p );
1651 return Search( v, p ) != End();
1659 return SearchSubset( i, j ) != End();
1664 template <
class FI,
class BP>
1667 return SearchSubset( i, j, p ) != End();
1675 return SearchSubset( c ) != End();
1680 template <
class C,
class BP>
1683 return SearchSubset( c, p ) != End();
1725 template <
class S,
typename SP>
1726 S& ToSeparated( S& s, SP separator )
const
1731 while ( *i ==
nullptr )
1734 s.Append( S( **i ) );
1737 if ( *i !=
nullptr )
1739 s.Append( separator );
1740 s.Append( S( **i ) );
1742 while ( ++i < End() );
1769 template <
class S,
typename SP,
class AF>
1770 S& ToSeparated( S& s, SP separator, AF append )
const
1775 while ( *i ==
nullptr )
1778 append( s, S( **i ) );
1783 if ( *i !=
nullptr )
1786 append( s, S( **i ) );
1788 while ( ++i < End() );
1803 S& ToCommaSeparated( S& s )
const
1805 return ToSeparated( s,
',' );
1817 S& ToSpaceSeparated( S& s )
const
1819 return ToSeparated( s,
' ' );
1831 S& ToTabSeparated( S& s )
const
1833 return ToSeparated( s,
'\t' );
1845 S& ToNewLineSeparated( S& s )
const
1847 return ToSeparated( s,
'\n' );
1862 return m_array.Hash64( seed );
1877 return m_array.Hash32( seed );
1893 array_implementation m_array;
1895 void DeleteObject( iterator i, allocator& a )
1903 void CloneObjects(
const C& x, DirectContainer<T>* )
1906 Reserve( x.Length() );
1907 Append(
static_cast<T*
>(
nullptr ), x.Length() );
1908 iterator i = Begin(), j = End();
1909 typename C::const_iterator p = x.Begin(), q = x.End();
1910 for ( allocator a; i < j && p != q; ++i, ++p )
1912 *i = a.Allocate( 1 );
1918 void CloneObjects(
const C& x, IndirectContainer<T>* )
1921 Reserve( x.Length() );
1922 Append(
static_cast<T*
>(
nullptr ), x.Length() );
1923 iterator i = Begin(), j = End();
1924 typename C::const_iterator p = x.Begin(), q = x.End();
1925 for ( allocator a; i < j && p != q; ++i, ++p )
1926 if ( *p !=
nullptr )
1928 *i = a.Allocate( 1 );
1942 template <
class T,
class A>
inline
1954 template <
class T,
class A>
inline
1967 template <
class T,
class A,
class V>
inline
1968 IndirectArray<T,A>&
operator <<( IndirectArray<T,A>& x,
const V* p )
1970 x.Append(
static_cast<const T*
>( p ) );
1981 template <
class T,
class A,
class V>
inline
1982 IndirectArray<T,A>&
operator <<( IndirectArray<T,A>&& x,
const V* p )
1984 x.Append(
static_cast<const T*
>( p ) );
1993 template <
class T,
class A>
inline
1994 IndirectArray<T,A>&
operator <<( IndirectArray<T,A>& x1,
const IndirectArray<T,A>& x2 )
2005 template <
class T,
class A>
inline
2006 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.
void Destroy(iterator i, size_type n=1)
size_type UpperBound() const
void Assign(const T *p, size_type n=1)
iterator SearchSubset(FI i, FI j, BP p) const
void Transfer(IndirectArray &x)
reverse_iterator ReverseEnd()
iterator MinItem(BP p) const
void Add(const IndirectArray &x)
void Truncate(const_iterator i)
T *const * const_iterator
IndirectArray(size_type n, const T *p)
const_iterator ConstBegin() const
iterator SearchLastSubset(BI i, BI j, BP p) const
void Delete(const T &v, BP p)
IndirectArray(FI i, FI j)
iterator LastThat(F f) const
iterator Replace(const_iterator i, const_iterator j, FI p, FI q)
void UniquifyIterators(iterator &i, iterator &j)
void Reserve(size_type n)
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)
iterator SearchSubset(const C &c, BP p) const
uint32 Hash32(uint32 seed=0) const
iterator ContainsSubset(const C &c) const
void Remove(const_iterator i, const_iterator j)
void Destroy(const T &v, BP p)
iterator Search(const T *p) const
iterator SearchSubset(const C &c) const
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
bool Contains(const T *p) const
iterator Search(const T &v) const
iterator SearchLastSubset(BI i, BI j) const
size_type Count(const T &v, BP p) const
reverse_iterator ReverseBegin()
iterator SearchLast(const T &v, 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)
uint64 Hash64(uint64 seed=0) const
size_type CountIf(UP p) const
size_type Capacity() const
const_reverse_iterator ConstReverseBegin() const
void Rotate(distance_type n)
void Assign(const IndirectArray &x)
iterator FirstThat(F f) const
bool IsAliasOf(const IndirectArray &x) 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)
void Append(const T *p, size_type n=1)
size_type LowerBound() const
void Add(const T *p, size_type n=1)
IndirectArray(const IndirectArray &)=default
void Prepend(const IndirectArray &x)
void Import(iterator i, iterator j)
iterator Search(const T &v, BP p) const
void ShiftLeft(const T *p, size_type n=1)
const_iterator begin() const
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 SearchLast(const T &v) const
iterator ContainsSubset(FI i, FI j, BP p) const
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
typename array_implementation::iterator array_iterator
void Append(const IndirectArray &x)
size_type Count(const T &v) const
iterator SearchLastSubset(const C &c, BP p) const
iterator SearchLastSubset(const C &c) const
iterator SearchLast(const T *p) const
iterator MaxItem(BP p) const
void Prepend(const T *p, size_type n=1)
iterator MutableIterator(const_iterator i)
iterator Replace(const_iterator i, const_iterator j, const T *p, size_type n=1)
void CloneAssign(const C &x)
const_reverse_iterator ConstReverseEnd() const
size_type Count(const T *p) const
iterator SearchSubset(FI i, FI j) 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...