52 #ifndef __PCL_ReferenceArray_h
53 #define __PCL_ReferenceArray_h
57 #include <pcl/Diagnostics.h>
94 template <
typename T,
class A = StandardAllocator>
195 T* operator ->()
const
389 const T* Pointer()
const
398 operator const T*()
const
416 const T* operator ->()
const
608 PCL_PRECONDITION( p !=
nullptr )
623 for ( ; i != j; ++i )
625 m_array.Append( *i );
655 return m_array.IsUnique();
666 return m_array.IsAliasOf( x.m_array );
679 m_array.EnsureUnique();
688 return m_array.Size();
696 return m_array.Length();
706 return m_array.Capacity();
718 return m_array.Available();
738 return m_array.IsValid();
746 return m_array.IsEmpty();
755 return m_array.LowerBound();
764 return m_array.UpperBound();
772 return m_array.Allocator();
780 m_array.SetAllocator( a );
813 return iterator( m_array.MutableIterator( i.it ) );
839 return **m_array.Begin();
848 return **m_array.Begin();
929 PCL_PRECONDITION( !IsEmpty() )
942 PCL_PRECONDITION( !IsEmpty() )
943 return iterator( m_array.Begin()-1 );
955 PCL_PRECONDITION( !IsEmpty() )
968 PCL_PRECONDITION( !IsEmpty() )
978 return **m_array.Begin();
985 const T& First()
const
987 return **m_array.Begin();
996 return **m_array.ReverseBegin();
1003 const T& Last()
const
1005 return **m_array.ReverseBegin();
1019 m_array.UniquifyIterator( i.it );
1034 m_array.UniquifyIterators( i.it, j.it );
1037 #ifndef __PCL_NO_STL_COMPATIBLE_ITERATORS
1094 m_array.Assign( x.m_array );
1117 m_array.Transfer( x.m_array );
1131 m_array.Transfer( std::move( x.m_array ) );
1143 m_array.Assign( p, n );
1161 for ( ; i != j; ++i )
1162 if ( *i !=
nullptr )
1163 m_array.Append( *i );
1179 PCL_ASSERT_CONTAINER( C, T );
1180 CloneObjects( x, (C*)
nullptr );
1190 m_array.Import( i.it, j.it );
1206 return m_array.Release();
1222 return iterator( m_array.Insert( i.it, x.m_array ) );
1238 return (p !=
nullptr) ?
iterator( m_array.Insert( i.it, p, n ) ) :
1260 for ( ; p != q; ++p )
1261 if ( *p !=
nullptr )
1262 it = m_array.Insert( it, *p );
1272 m_array.Append( x.m_array );
1284 m_array.Append( p, n );
1299 for ( ; p != q; ++p )
1300 if ( *p !=
nullptr )
1301 m_array.Append( *p );
1310 m_array.Prepend( x.m_array );
1322 m_array.Prepend( p, n );
1337 for ( ; p != q; ++p )
1338 if ( *p !=
nullptr )
1339 m_array.Prepend( *p );
1376 m_array.Remove( i.it, n );
1388 m_array.Remove( i.it, j.it );
1405 m_array.RemoveFirst( n );
1422 m_array.RemoveLast( n );
1440 m_array.Truncate( i.it );
1449 m_array.Shrink( n );
1461 m_array.Remove( v );
1474 m_array.Remove( v, p );
1485 m_array.Remove( p );
1520 m_array.Destroy( i.it, n );
1543 m_array.Destroy( i.it, j.it );
1558 m_array.Destroy( v );
1575 m_array.Destroy( v, p );
1605 return iterator( m_array.Replace( i.it, j.it, x.m_array ) );
1618 return iterator( m_array.Replace( i.it, j.it, p, (p !=
nullptr) ? n :
size_type( 0 ) ) );
1642 for ( ; p != q; ++p )
1643 if ( *p !=
nullptr )
1645 return iterator( m_array.Replace( i.it, j.it, m ) );
1657 m_array.Reserve( n );
1682 pcl::Fill( Begin(), End(), v );
1766 return m_array.Count( p );
1860 m_array.Rotate( n );
1867 m_array.ShiftLeft( p, n );
1874 m_array.ShiftRight( p, n );
1902 return iterator( m_array.Search( p ) );
1946 return iterator( m_array.SearchLast( p ) );
1983 template <
class FI,
class BP>
1991 template <
class FI,
class BP>
2015 template <
class C,
class BP>
2023 template <
class C,
class BP>
2047 template <
class BI,
class BP>
2055 template <
class BI,
class BP>
2079 template <
class C,
class BP>
2087 template <
class C,
class BP>
2097 return Search( v ) != End();
2104 return m_array.Contains( p );
2112 return Search( v, p ) != End();
2120 return SearchSubset( i, j ) != End();
2125 template <
class FI,
class BP>
2128 return SearchSubset( i, j, p ) != End();
2136 return m_array.ContainsSubset( c );
2141 template <
class C,
class BP>
2144 return SearchSubset( c ) != End();
2152 [](
const T* a,
const T* b ){ return *a < *b; } );
2161 [p](
const T* a,
const T* b ){ return p( *a, *b ); } );
2188 template <
class S,
typename SP>
2189 S& ToSeparated( S& s, SP separator )
const
2194 s.Append( S( *i ) );
2198 s.Append( separator );
2199 s.Append( S( *i ) );
2201 while ( ++i < End() );
2228 template <
class S,
typename SP,
class AF>
2229 S& ToSeparated( S& s, SP separator, AF append )
const
2234 append( s, S( *i ) );
2241 append( s, S( *i ) );
2243 while ( ++i < End() );
2258 S& ToCommaSeparated( S& s )
const
2260 return ToSeparated( s,
',' );
2272 S& ToSpaceSeparated( S& s )
const
2274 return ToSeparated( s,
' ' );
2286 S& ToTabSeparated( S& s )
const
2288 return ToSeparated( s,
'\t' );
2300 S& ToNewLineSeparated( S& s )
const
2302 return ToSeparated( s,
'\n' );
2317 return m_array.Hash64( seed );
2332 return m_array.Hash32( seed );
2346 array_implementation m_array;
2351 m_array.CloneAssign( x );
2355 void CloneObjects(
const C& x, IndirectContainer<T>* )
2358 m_array.Reserve( x.Length() );
2360 for (
typename C::const_iterator p = x.Begin(); p != x.End(); ++p )
2361 if ( *p !=
nullptr )
2363 T* o = a.Allocate( 1 );
2365 m_array.Append( o );
2378 template <
class T,
class A>
inline
2390 template <
class T,
class A>
inline
2403 template <
class T,
class A,
class V>
inline
2404 ReferenceArray<T,A>&
operator <<( ReferenceArray<T,A>& x,
const V* p )
2406 x.Append(
static_cast<const T*
>( p ) );
2417 template <
class T,
class A,
class V>
inline
2418 ReferenceArray<T,A>&
operator <<( ReferenceArray<T,A>&& x,
const V* p )
2420 x.Append(
static_cast<const T*
>( p ) );
2429 template <
class T,
class A>
inline
2430 ReferenceArray<T,A>&
operator <<( ReferenceArray<T,A>& x1,
const ReferenceArray<T,A>& x2 )
2441 template <
class T,
class A>
inline
2442 ReferenceArray<T,A>&
operator <<( ReferenceArray<T,A>&& x1,
const ReferenceArray<T,A>& x2 )
Provides memory allocation for PCL containers.
Root base class of all PCL containers of objects.
Generic dynamic array of pointers to objects.
T *const * const_iterator
void Append(const IndirectArray &x)
Random access iterator class.
Immutable ReferenceArray iterator.
const_iterator(const const_iterator &)=default
const_iterator(const iterator &i)
const_iterator(std::nullptr_t)
Immutable ReferenceArray reverse iterator.
Mutable ReferenceArray iterator.
iterator(const iterator &)=default
Mutable ReferenceArray reverse iterator.
Dynamic array of pointers to objects providing direct iteration and element access by reference.
iterator SearchLast(const T *p)
void CloneAssign(const C &x)
iterator Search(const T &v, BP p)
iterator Insert(const_iterator i, FI p, FI q)
const_iterator SearchSubset(const C &c) const
iterator ContainsSubset(FI i, FI j, BP p) const
iterator Insert(const_iterator i, const T *p, size_type n=1)
reverse_iterator ReverseBegin()
void RemovePointer(const T *p)
void Remove(const T &v, BP p)
void Assign(const ReferenceArray &x)
void ShiftLeft(const T *p, size_type n=1)
const_iterator MaxItem() const
const_reverse_iterator ConstReverseBegin() const
ReferenceArray(FI i, FI j)
const_iterator ConstBegin() const
iterator Replace(const_iterator i, const_iterator j, const T *p, size_type n=1)
const_iterator SearchLastSubset(const C &c) const
iterator ContainsSubset(FI i, FI j) const
const_reverse_iterator ReverseEnd() const
const_iterator SearchSubset(FI i, FI j) const
void Transfer(ReferenceArray &&x)
const_reverse_iterator ConstReverseEnd() const
size_type Count(const T *p) const
void Destroy(iterator i, iterator j)
size_type Capacity() const
iterator MutableIterator(const_iterator i)
void Append(const T *p, size_type n=1)
void Destroy(iterator i, size_type n=1)
void Append(const ReferenceArray &x)
void Assign(const T *p, size_type n=1)
iterator SearchSubset(const C &c, BP p)
const_iterator MinItem(BP p) const
const_iterator ConstEnd() const
typename array_implementation::iterator indirect_iterator
iterator Search(const T *p)
const_iterator Search(const T &v) const
const_iterator SearchLastSubset(const C &c, BP p) const
void UniquifyIterators(iterator &i, iterator &j)
void Prepend(const T *p, size_type n=1)
const_iterator MaxItem(BP p) const
uint32 Hash32(uint32 seed=0) const
size_type Count(const T &v) const
friend void Swap(ReferenceArray &x1, ReferenceArray &x2)
size_type CountIf(UP p) const
const_iterator Search(const T &v, BP p) const
void Destroy(const T &v, BP p)
bool Contains(const T *p) const
const_reverse_iterator ReverseBegin() const
const_iterator FirstThat(F f) const
const allocator & Allocator() const
iterator SearchLastSubset(BI i, BI j, BP p)
iterator SearchSubset(FI i, FI j, BP p)
const_iterator begin() const
size_type Available() const
reverse_iterator ReverseEnd()
iterator SearchLastSubset(BI i, BI j)
size_type Count(const T &v, BP p) const
iterator SearchLastSubset(const C &c, BP p)
const_iterator SearchLast(const T &v, BP p) const
iterator SearchLast(const T &v, BP p)
void RemoveFirst(size_type n=1)
void Reserve(size_type n)
bool Contains(const T &v) const
const_iterator SearchLastSubset(BI i, BI j, BP p) const
uint64 Hash64(uint64 seed=0) const
void Remove(const_iterator i, const_iterator j)
const_iterator Begin() const
void ShiftRight(const T *p, size_type n=1)
const_iterator Search(const T *p) const
const_iterator MinItem() const
iterator ContainsSubset(const C &c, BP p) const
const_iterator SearchLastSubset(BI i, BI j) const
const_iterator End() const
bool Contains(const T &v, BP p) const
indirect_iterator Release()
void Add(const ReferenceArray &x)
const_iterator LastThat(F f) const
void Remove(const_iterator i, size_type n=1)
typename array_implementation::const_iterator const_indirect_iterator
void Add(const T *p, size_type n=1)
typename array_implementation::allocator allocator
const_iterator SearchLast(const T *p) const
iterator Replace(const_iterator i, const_iterator j, const ReferenceArray &x)
const_iterator SearchSubset(const C &c, BP p) const
ReferenceArray(size_type n, const T *p)
void UniquifyIterator(iterator &i)
ReferenceArray(ReferenceArray &&)=default
bool IsAliasOf(const ReferenceArray &x) const
const_iterator SearchLast(const T &v) const
size_type LowerBound() const
void SetAllocator(const allocator &a)
const_iterator SearchSubset(FI i, FI j, BP p) const
void Prepend(const ReferenceArray &x)
iterator Insert(const_iterator i, const ReferenceArray &x)
void RemoveLast(size_type n=1)
void Shrink(size_type n=1)
const_iterator At(size_type i) const
uint64 Hash(uint64 seed=0) const
size_type UpperBound() const
void Transfer(ReferenceArray &x)
iterator Replace(const_iterator i, const_iterator j, FI p, FI q)
void Rotate(distance_type n)
iterator Search(const T &v)
typename array_implementation::block_allocator block_allocator
iterator SearchSubset(const C &c)
iterator ContainsSubset(const C &c) const
const_iterator end() const
void Truncate(const_iterator i)
iterator SearchLastSubset(const C &c)
void Import(iterator i, iterator j)
iterator SearchSubset(FI i, FI j)
ReferenceArray(const ReferenceArray &)=default
iterator SearchLast(const T &v)
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
Complex< T1 > operator*(const Complex< T1 > &c1, const Complex< T2 > &c2) 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))
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
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))
Generic container iterator.
T item_type
Represents the item type.