PCL
Array.h
Go to the documentation of this file.
1 // ____ ______ __
2 // / __ \ / ____// /
3 // / /_/ // / / /
4 // / ____// /___ / /___ PixInsight Class Library
5 // /_/ \____//_____/ PCL 2.7.0
6 // ----------------------------------------------------------------------------
7 // pcl/Array.h - Released 2024-06-18T15:48:54Z
8 // ----------------------------------------------------------------------------
9 // This file is part of the PixInsight Class Library (PCL).
10 // PCL is a multiplatform C++ framework for development of PixInsight modules.
11 //
12 // Copyright (c) 2003-2024 Pleiades Astrophoto S.L. All Rights Reserved.
13 //
14 // Redistribution and use in both source and binary forms, with or without
15 // modification, is permitted provided that the following conditions are met:
16 //
17 // 1. All redistributions of source code must retain the above copyright
18 // notice, this list of conditions and the following disclaimer.
19 //
20 // 2. All redistributions in binary form must reproduce the above copyright
21 // notice, this list of conditions and the following disclaimer in the
22 // documentation and/or other materials provided with the distribution.
23 //
24 // 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
25 // of their contributors, may be used to endorse or promote products derived
26 // from this software without specific prior written permission. For written
27 // permission, please contact info@pixinsight.com.
28 //
29 // 4. All products derived from this software, in any form whatsoever, must
30 // reproduce the following acknowledgment in the end-user documentation
31 // and/or other materials provided with the product:
32 //
33 // "This product is based on software from the PixInsight project, developed
34 // by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
35 //
36 // Alternatively, if that is where third-party acknowledgments normally
37 // appear, this acknowledgment must be reproduced in the product itself.
38 //
39 // THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
40 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
41 // TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
43 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
44 // EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
45 // INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
46 // DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
47 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
49 // POSSIBILITY OF SUCH DAMAGE.
50 // ----------------------------------------------------------------------------
51 
52 #ifndef __PCL_Array_h
53 #define __PCL_Array_h
54 
56 
57 #include <pcl/Defs.h>
58 #include <pcl/Diagnostics.h>
59 
60 #include <pcl/Allocator.h>
61 #include <pcl/Container.h>
62 #include <pcl/Indirect.h>
63 #include <pcl/Iterator.h>
64 #include <pcl/Math.h>
65 #include <pcl/Memory.h>
66 #include <pcl/ReferenceCounter.h>
67 #include <pcl/Relational.h>
68 #include <pcl/Rotate.h>
69 #include <pcl/Search.h>
70 #include <pcl/Sort.h>
71 #include <pcl/StandardAllocator.h>
72 #include <pcl/Utility.h>
73 
74 namespace pcl
75 {
76 
77 // ----------------------------------------------------------------------------
78 
83 // ----------------------------------------------------------------------------
84 
98 template <class T, class A = StandardAllocator>
99 class PCL_CLASS Array : public DirectContainer<T>
100 {
101 public:
102 
105  using block_allocator = A;
106 
110 
113  using iterator = T*;
114 
117  using const_iterator = const T*;
118 
122 
126 
127  // -------------------------------------------------------------------------
128 
133  {
134  m_data = new Data;
135  }
136 
140  explicit
142  {
143  m_data = new Data;
144  m_data->Allocate( n );
145  m_data->Initialize( m_data->begin, m_data->end );
146  }
147 
151  Array( size_type n, const T& v )
152  {
153  m_data = new Data;
154  m_data->Allocate( n );
155  m_data->Initialize( m_data->begin, m_data->end, v );
156  }
157 
162  template <class FI>
163  Array( FI i, FI j )
164  {
165  m_data = new Data;
166  m_data->Allocate( size_type( pcl::Distance( i, j ) ) );
167  if ( m_data->begin != nullptr )
168  m_data->Build( m_data->begin, i, j );
169  }
170 
179  template <typename T1>
180  Array( std::initializer_list<T1> l )
181  : Array( l.begin(), l.end() )
182  {
183  }
184 
188  Array( const Array& x )
189  : m_data( x.m_data )
190  {
191  if ( m_data != nullptr )
192  m_data->Attach();
193  }
194 
198  Array( Array&& x )
199  : m_data( x.m_data )
200  {
201  x.m_data = nullptr;
202  }
203 
209  {
210  if ( m_data != nullptr )
211  {
212  DetachFromData();
213  m_data = nullptr;
214  }
215  }
216 
220  bool IsUnique() const noexcept
221  {
222  return m_data->IsUnique();
223  }
224 
230  bool IsAliasOf( const Array& x ) const noexcept
231  {
232  return m_data == x.m_data;
233  }
234 
243  {
244  if ( !IsUnique() )
245  {
246  Data* newData = new Data;
247  newData->Allocate( Length() );
248  newData->Build( newData->begin, m_data->begin, m_data->end );
249  DetachFromData();
250  m_data = newData;
251  }
252  }
253 
258  size_type Size() const noexcept
259  {
260  return m_data->Size();
261  }
262 
266  size_type Length() const noexcept
267  {
268  return m_data->Length();
269  }
270 
275  size_type Capacity() const noexcept
276  {
277  return m_data->Capacity();
278  }
279 
286  size_type Available() const noexcept
287  {
288  return m_data->Available();
289  }
290 
304  bool IsValid() const noexcept
305  {
306  return m_data != nullptr;
307  }
308 
312  bool IsEmpty() const noexcept
313  {
314  return m_data->IsEmpty();
315  }
316 
321  size_type LowerBound() const noexcept
322  {
323  return 0;
324  }
325 
330  size_type UpperBound() const noexcept
331  {
332  return Length()-1;
333  }
334 
338  const allocator& Allocator() const noexcept
339  {
340  return m_data->alloc;
341  }
342 
346  void SetAllocator( const allocator& a )
347  {
348  EnsureUnique();
349  m_data->alloc = a;
350  }
351 
356  {
357  PCL_PRECONDITION( !IsEmpty() && i < Length() )
358  EnsureUnique();
359  return m_data->begin + i;
360  }
361 
365  const_iterator At( size_type i ) const noexcept
366  {
367  PCL_PRECONDITION( !IsEmpty() && i < Length() )
368  return m_data->begin + i;
369  }
370 
382  {
383  return At( i - m_data->begin );
384  }
385 
390  T& operator []( size_type i )
391  {
392  return *At( i );
393  }
394 
399  const T& operator []( size_type i ) const noexcept
400  {
401  return *At( i );
402  }
403 
408  {
409  PCL_PRECONDITION( m_data->begin != nullptr )
410  EnsureUnique();
411  return *m_data->begin;
412  }
413 
417  const T& operator *() const noexcept
418  {
419  PCL_PRECONDITION( m_data->begin != nullptr )
420  return *m_data->begin;
421  }
422 
427  {
428  EnsureUnique();
429  return m_data->begin;
430  }
431 
435  const_iterator Begin() const noexcept
436  {
437  return m_data->begin;
438  }
439 
443  const_iterator ConstBegin() const noexcept
444  {
445  return m_data->begin;
446  }
447 
452  {
453  EnsureUnique();
454  return m_data->end;
455  }
456 
460  const_iterator End() const noexcept
461  {
462  return m_data->end;
463  }
464 
468  const_iterator ConstEnd() const noexcept
469  {
470  return m_data->end;
471  }
472 
480  {
481  PCL_PRECONDITION( m_data->end != nullptr )
482  EnsureUnique();
483  return m_data->end - 1;
484  }
485 
493  {
494  PCL_PRECONDITION( m_data->end != nullptr )
495  return m_data->end - 1;
496  }
497 
505  {
506  PCL_PRECONDITION( m_data->end != nullptr )
507  return m_data->end - 1;
508  }
509 
518  {
519  PCL_PRECONDITION( m_data->begin != nullptr )
520  EnsureUnique();
521  return m_data->begin - 1;
522  }
523 
532  {
533  PCL_PRECONDITION( m_data->begin != nullptr )
534  return m_data->begin - 1;
535  }
536 
545  {
546  PCL_PRECONDITION( m_data->begin != nullptr )
547  return m_data->begin - 1;
548  }
549 
559  {
560  PCL_PRECONDITION( i >= m_data->begin && i <= m_data->end )
561  if ( !IsUnique() )
562  {
563  distance_type d = i - m_data->begin;
564  EnsureUnique();
565  i = m_data->begin + d;
566  }
567  }
568 
579  {
580  PCL_PRECONDITION( i >= m_data->begin && i <= m_data->end )
581  PCL_PRECONDITION( j >= m_data->begin && j <= m_data->end )
582  if ( !IsUnique() )
583  {
584  distance_type d = i - m_data->begin;
585  distance_type r = j - i;
586  EnsureUnique();
587  j = (i = m_data->begin + d) + r;
588  }
589  }
590 
591 #ifndef __PCL_NO_STL_COMPATIBLE_ITERATORS
596  {
597  return Begin();
598  }
599 
603  const_iterator begin() const noexcept
604  {
605  return Begin();
606  }
607 
612  {
613  return End();
614  }
615 
619  const_iterator end() const noexcept
620  {
621  return End();
622  }
623 #endif // !__PCL_NO_STL_COMPATIBLE_ITERATORS
624 
631  Array& operator =( const Array& x )
632  {
633  Assign( x );
634  return *this;
635  }
636 
646  void Assign( const Array& x )
647  {
648  x.m_data->Attach();
649  DetachFromData();
650  m_data = x.m_data;
651  }
652 
656  Array& operator =( Array&& x )
657  {
658  Transfer( x );
659  return *this;
660  }
661 
671  void Transfer( Array& x )
672  {
673  DetachFromData();
674  m_data = x.m_data;
675  x.m_data = nullptr;
676  }
677 
687  void Transfer( Array&& x )
688  {
689  DetachFromData();
690  m_data = x.m_data;
691  x.m_data = nullptr;
692  }
693 
698  void Assign( const T& v, size_type n = 1 )
699  {
700  if ( n > 0 )
701  {
702  if ( !IsUnique() )
703  {
704  Data* newData = new Data;
705  DetachFromData();
706  m_data = newData;
707  }
708 
709  if ( Capacity() < n )
710  {
711  m_data->Deallocate();
712  m_data->Allocate( n );
713  }
714  else
715  {
716  m_data->Destroy( m_data->begin, m_data->end );
717  m_data->end = m_data->begin + n;
718  }
719 
720  m_data->Initialize( m_data->begin, m_data->end, v );
721  }
722  else
723  Clear();
724  }
725 
732  template <class FI>
733  void Assign( FI i, FI j )
734  {
735  size_type n = size_type( pcl::Distance( i, j ) );
736  if ( n > 0 )
737  {
738  if ( !IsUnique() )
739  {
740  Data* newData = new Data;
741  DetachFromData();
742  m_data = newData;
743  }
744 
745  if ( Capacity() < n )
746  {
747  m_data->Deallocate();
748  m_data->Allocate( n );
749  }
750  else
751  {
752  m_data->Destroy( m_data->begin, m_data->end );
753  m_data->end = m_data->begin + n;
754  }
755 
756  m_data->Build( m_data->begin, i, j );
757  }
758  else
759  Clear();
760  }
761 
771  void Import( iterator i, iterator j )
772  {
773  if ( i >= m_data->available || j <= m_data->begin )
774  {
775  Clear();
776  size_type n = size_type( pcl::Distance( i, j ) );
777  if ( n > 0 )
778  {
779  EnsureUnique();
780  m_data->begin = i;
781  m_data->end = m_data->available = j;
782  }
783  }
784  }
785 
799  {
800  EnsureUnique();
801  iterator b = m_data->begin;
802  m_data->begin = m_data->end = m_data->available = nullptr;
803  return b;
804  }
805 
817  {
818  i = pcl::Range( i, m_data->begin, m_data->end );
819  if ( n > 0 )
820  {
821  UniquifyIterator( i );
822  m_data->Initialize( i = m_data->UninitializedGrow( i, n ), n );
823  }
824  return i;
825  }
826 
837  {
838  return Grow( m_data->end, n );
839  }
840 
845  void Shrink( size_type n = 1 )
846  {
847  RemoveLast( n );
848  }
849 
862  void Resize( size_type n )
863  {
864  size_type l = m_data->Length();
865  if ( n > l )
866  Expand( n - l );
867  else
868  Shrink( l - n );
869  }
870 
882  iterator Insert( iterator i, const Array& x )
883  {
884  if ( &x != this )
885  return Insert( i, x.Begin(), x.End() );
886  Array t( *this );
887  t.EnsureUnique();
888  return Insert( i, t.m_data->begin, t.m_data->end );
889  }
890 
901  iterator Insert( iterator i, const T& v, size_type n = 1 )
902  {
903  i = pcl::Range( i, m_data->begin, m_data->end );
904  if ( n > 0 )
905  {
906  UniquifyIterator( i );
907  m_data->Initialize( i = m_data->UninitializedGrow( i, n ), n, v );
908  }
909  return i;
910  }
911 
924  template <class FI>
925  iterator Insert( iterator i, FI p, FI q )
926  {
927  i = pcl::Range( i, m_data->begin, m_data->end );
928  size_type n = size_type( pcl::Distance( p, q ) );
929  if ( n > 0 )
930  {
931  UniquifyIterator( i );
932  m_data->Build( i = m_data->UninitializedGrow( i, n ), p, q );
933  }
934  return i;
935  }
936 
940  void Append( const Array& x )
941  {
942  Insert( m_data->end, x );
943  }
944 
949  void Append( const T& v, size_type n = 1 )
950  {
951  Insert( m_data->end, v, n );
952  }
953 
960  template <class FI>
961  void Append( FI p, FI q )
962  {
963  Insert( m_data->end, p, q );
964  }
965 
970  void Prepend( const Array& x )
971  {
972  Insert( m_data->begin, x );
973  }
974 
979  void Prepend( const T& v, size_type n = 1 )
980  {
981  Insert( m_data->begin, v, n );
982  }
983 
990  template <class FI>
991  void Prepend( FI p, FI q )
992  {
993  Insert( m_data->begin, p, q );
994  }
995 
999  void Add( const Array& x )
1000  {
1001  Append( x );
1002  }
1003 
1007  void Add( const T& v, size_type n = 1 )
1008  {
1009  Append( v, n );
1010  }
1011 
1015  template <class FI>
1016  void Add( FI p, FI q )
1017  {
1018  Append( p, q );
1019  }
1020 
1030  void Remove( iterator i, size_type n = 1 )
1031  {
1032  Remove( i, i+n );
1033  }
1034 
1044  void Remove( iterator i, iterator j )
1045  {
1046  if ( i < m_data->end )
1047  if ( i < j )
1048  {
1049  i = pcl::Max( m_data->begin, i );
1050  j = pcl::Min( j, m_data->end );
1051  if ( i > m_data->begin || j < m_data->end )
1052  {
1053  UniquifyIterators( i, j );
1054  m_data->Destroy( j = pcl::Copy( i, j, m_data->end ), m_data->end );
1055  m_data->end = j;
1056  }
1057  else
1058  Clear();
1059  }
1060  }
1061 
1071  void RemoveFirst( size_type n = 1 )
1072  {
1073  Remove( m_data->begin, m_data->begin + pcl::Min( n, m_data->Length() ) );
1074  }
1075 
1085  void RemoveLast( size_type n = 1 )
1086  {
1087  Remove( m_data->end - pcl::Min( n, m_data->Length() ), m_data->end );
1088  }
1089 
1100  void Truncate( iterator i )
1101  {
1102  Remove( i, m_data->end );
1103  }
1104 
1109  void Remove( const T& v )
1110  {
1111  Array a;
1112  for ( iterator i = m_data->begin, j = i; ; ++j )
1113  {
1114  if ( j == m_data->end )
1115  {
1116  if ( i != m_data->begin )
1117  {
1118  a.Add( i, j );
1119  Transfer( a );
1120  }
1121  break;
1122  }
1123 
1124  if ( *j == v )
1125  {
1126  a.Add( i, j );
1127  i = j;
1128  ++i;
1129  }
1130  }
1131  }
1132 
1137  template <class BP>
1138  void Remove( const T& v, BP p )
1139  {
1140  Array a;
1141  for ( iterator i = m_data->begin, j = i; ; ++j )
1142  {
1143  if ( j == m_data->end )
1144  {
1145  if ( i != m_data->begin )
1146  {
1147  a.Add( i, j );
1148  Transfer( a );
1149  }
1150  break;
1151  }
1152 
1153  if ( p( *j, v ) )
1154  {
1155  a.Add( i, j );
1156  i = j;
1157  ++i;
1158  }
1159  }
1160  }
1161 
1173  void Clear()
1174  {
1175  if ( !IsEmpty() )
1176  if ( IsUnique() )
1177  m_data->Deallocate();
1178  else
1179  {
1180  Data* newData = new Data;
1181  DetachFromData();
1182  m_data = newData;
1183  }
1184  }
1185 
1200  {
1201  if ( &x != this )
1202  return Replace( i, j, x.Begin(), x.End() );
1203  Array t( *this );
1204  t.EnsureUnique();
1205  return Replace( i, j, t.ConstBegin(), t.ConstEnd() );
1206  }
1207 
1221  iterator Replace( iterator i, iterator j, const T& v, size_type n = 1 )
1222  {
1223  i = pcl::Range( i, m_data->begin, m_data->end );
1224  j = pcl::Range( j, m_data->begin, m_data->end );
1225  if ( i < j )
1226  if ( i < m_data->end )
1227  {
1228  UniquifyIterators( i, j );
1229  size_type d = size_type( j - i );
1230  if ( d < n )
1231  {
1232  m_data->Destroy( i, j );
1233  m_data->Initialize( i = m_data->UninitializedGrow( i, n-d ), n, v );
1234  }
1235  else
1236  {
1237  iterator k = i + n;
1238  pcl::Fill( i, k, v );
1239  Remove( k, j );
1240  if ( m_data->begin == nullptr )
1241  i = nullptr;
1242  }
1243  }
1244  return i;
1245  }
1246 
1263  template <class FI>
1264  iterator Replace( iterator i, iterator j, FI p, FI q )
1265  {
1266  i = pcl::Range( i, m_data->begin, m_data->end );
1267  j = pcl::Range( j, m_data->begin, m_data->end );
1268  if ( i < j )
1269  if ( i < m_data->end )
1270  {
1271  UniquifyIterators( i, j );
1272  size_type d = size_type( j - i );
1273  size_type n = size_type( pcl::Distance( p, q ) );
1274  if ( d < n )
1275  {
1276  m_data->Destroy( i, j );
1277  m_data->Build( i = m_data->UninitializedGrow( i, n-d ), p, q );
1278  }
1279  else
1280  {
1281  Remove( pcl::Move( i, p, q ), j );
1282  if ( m_data->begin == nullptr )
1283  i = nullptr;
1284  }
1285  }
1286  return i;
1287  }
1288 
1295  void Reserve( size_type n )
1296  {
1297  if ( n > 0 )
1298  if ( IsUnique() )
1299  {
1300  if ( Capacity() < n )
1301  {
1302  iterator b = m_data->alloc.Allocate( n );
1303  iterator e = m_data->Build( b, m_data->begin, m_data->end );
1304  m_data->Deallocate();
1305  m_data->begin = b;
1306  m_data->end = e;
1307  m_data->available = m_data->begin + n;
1308  }
1309  }
1310  else
1311  {
1312  Data* newData = new Data;
1313  newData->begin = newData->alloc.Allocate( n = pcl::Max( Length(), n ) );
1314  newData->end = newData->Build( newData->begin, m_data->begin, m_data->end );
1315  newData->available = newData->begin + n;
1316  DetachFromData();
1317  m_data = newData;
1318  }
1319  }
1320 
1333  void Squeeze()
1334  {
1335  if ( IsUnique() )
1336  {
1337  if ( Available() > 0 )
1338  {
1339  iterator b = m_data->alloc.Allocate( Length() );
1340  iterator e = m_data->Build( b, m_data->begin, m_data->end );
1341  m_data->Deallocate();
1342  m_data->begin = b;
1343  m_data->end = m_data->available = e;
1344  }
1345  }
1346  else
1347  {
1348  Data* newData = new Data;
1349  if ( !IsEmpty() )
1350  {
1351  newData->begin = newData->alloc.Allocate( Length() );
1352  newData->available = newData->end = newData->Build( newData->begin, m_data->begin, m_data->end );
1353  }
1354  DetachFromData();
1355  m_data = newData;
1356  }
1357  }
1358 
1362  void Fill( const T& v )
1363  {
1364  EnsureUnique();
1365  pcl::Fill( m_data->begin, m_data->end, v );
1366  }
1367 
1380  void SecureFill( const T& v )
1381  {
1382  pcl::Fill( m_data->begin, m_data->end, v );
1383  }
1384 
1389  template <class F>
1390  void Apply( F f )
1391  {
1392  EnsureUnique();
1393  pcl::Apply( m_data->begin, m_data->end, f );
1394  }
1395 
1400  template <class F>
1401  void Apply( F f ) const noexcept( noexcept( f ) )
1402  {
1403  pcl::Apply( m_data->begin, m_data->end, f );
1404  }
1405 
1411  template <class F>
1412  const_iterator FirstThat( F f ) const noexcept( noexcept( f ) )
1413  {
1414  return pcl::FirstThat( m_data->begin, m_data->end, f );
1415  }
1416 
1422  template <class F>
1424  {
1425  EnsureUnique();
1426  return pcl::FirstThat( m_data->begin, m_data->end, f );
1427  }
1428 
1434  template <class F>
1435  const_iterator LastThat( F f ) const noexcept( noexcept( f ) )
1436  {
1437  return pcl::LastThat( m_data->begin, m_data->end, f );
1438  }
1439 
1442  size_type Count( const T& v ) const noexcept
1443  {
1444  return pcl::Count( m_data->begin, m_data->end, v );
1445  }
1446 
1449  template <class BP>
1450  size_type Count( const T& v, BP p ) const noexcept( noexcept( p ) )
1451  {
1452  return pcl::Count( m_data->begin, m_data->end, v, p );
1453  }
1454 
1457  template <class UP>
1458  size_type CountIf( UP p ) const noexcept( noexcept( p ) )
1459  {
1460  return pcl::CountIf( m_data->begin, m_data->end, p );
1461  }
1462 
1465  const_iterator MinItem() const noexcept
1466  {
1467  return pcl::MinItem( m_data->begin, m_data->end );
1468  }
1469 
1473  {
1474  EnsureUnique();
1475  return pcl::MinItem( m_data->begin, m_data->end );
1476  }
1477 
1480  template <class BP>
1481  const_iterator MinItem( BP p ) const noexcept( noexcept( p ) )
1482  {
1483  return pcl::MinItem( m_data->begin, m_data->end, p );
1484  }
1485 
1488  template <class BP>
1490  {
1491  EnsureUnique();
1492  return pcl::MinItem( m_data->begin, m_data->end, p );
1493  }
1494 
1497  const_iterator MaxItem() const noexcept
1498  {
1499  return pcl::MaxItem( m_data->begin, m_data->end );
1500  }
1501 
1505  {
1506  EnsureUnique();
1507  return pcl::MaxItem( m_data->begin, m_data->end );
1508  }
1509 
1512  template <class BP>
1513  const_iterator MaxItem( BP p ) const noexcept( noexcept( p ) )
1514  {
1515  return pcl::MaxItem( m_data->begin, m_data->end, p );
1516  }
1517 
1520  template <class BP>
1522  {
1523  EnsureUnique();
1524  return pcl::MaxItem( m_data->begin, m_data->end, p );
1525  }
1526 
1529  void Reverse()
1530  {
1531  EnsureUnique();
1532  pcl::Reverse( m_data->begin, m_data->end );
1533  }
1534 
1538  {
1539  if ( Length() > 1 && n != 0 )
1540  {
1541  EnsureUnique();
1542  if ( (n %= Length()) < 0 )
1543  n += Length();
1544  pcl::Rotate( m_data->begin, m_data->begin+n, m_data->end );
1545  }
1546  }
1547 
1550  void ShiftLeft( const T& v, size_type n = 1 )
1551  {
1552  if ( !IsEmpty() && n > 0 )
1553  {
1554  EnsureUnique();
1555  if ( n >= Length() )
1556  pcl::Fill( m_data->begin, m_data->end, v );
1557  else
1558  pcl::ShiftLeft( m_data->begin, m_data->begin+n, m_data->end, v );
1559  }
1560  }
1561 
1564  void ShiftRight( const T& v, size_type n = 1 )
1565  {
1566  if ( !IsEmpty() && n > 0 )
1567  {
1568  EnsureUnique();
1569  if ( n >= Length() )
1570  pcl::Fill( m_data->begin, m_data->end, v );
1571  else
1572  pcl::ShiftRight( m_data->begin, m_data->end-n, m_data->end, v );
1573  }
1574  }
1575 
1578  const_iterator Search( const T& v ) const noexcept
1579  {
1580  return pcl::LinearSearch( m_data->begin, m_data->end, v );
1581  }
1582 
1585  iterator Search( const T& v )
1586  {
1587  EnsureUnique();
1588  return pcl::LinearSearch( m_data->begin, m_data->end, v );
1589  }
1590 
1593  template <class BP>
1594  const_iterator Search( const T& v, BP p ) const noexcept( noexcept( p ) )
1595  {
1596  return pcl::LinearSearch( m_data->begin, m_data->end, v, p );
1597  }
1598 
1601  template <class BP>
1602  iterator Search( const T& v, BP p )
1603  {
1604  EnsureUnique();
1605  return pcl::LinearSearch( m_data->begin, m_data->end, v, p );
1606  }
1607 
1610  const_iterator SearchLast( const T& v ) const noexcept
1611  {
1612  return pcl::LinearSearchLast( m_data->begin, m_data->end, v );
1613  }
1614 
1617  iterator SearchLast( const T& v )
1618  {
1619  EnsureUnique();
1620  return pcl::LinearSearchLast( m_data->begin, m_data->end, v );
1621  }
1622 
1625  template <class BP>
1626  const_iterator SearchLast( const T& v, BP p ) const noexcept( noexcept( p ) )
1627  {
1628  return pcl::LinearSearchLast( m_data->begin, m_data->end, v, p );
1629  }
1630 
1633  template <class BP>
1634  iterator SearchLast( const T& v, BP p )
1635  {
1636  EnsureUnique();
1637  return pcl::LinearSearchLast( m_data->begin, m_data->end, v, p );
1638  }
1639 
1642  template <class FI>
1643  const_iterator SearchSubset( FI i, FI j ) const noexcept
1644  {
1645  return pcl::Search( m_data->begin, m_data->end, i, j );
1646  }
1647 
1650  template <class FI>
1651  iterator SearchSubset( FI i, FI j )
1652  {
1653  EnsureUnique();
1654  return pcl::Search( m_data->begin, m_data->end, i, j );
1655  }
1656 
1659  template <class FI, class BP>
1660  const_iterator SearchSubset( FI i, FI j, BP p ) const noexcept( noexcept( p ) )
1661  {
1662  return pcl::Search( m_data->begin, m_data->end, i, j, p );
1663  }
1664 
1667  template <class FI, class BP>
1668  iterator SearchSubset( FI i, FI j, BP p )
1669  {
1670  EnsureUnique();
1671  return pcl::Search( m_data->begin, m_data->end, i, j, p );
1672  }
1673 
1676  template <class C>
1677  const_iterator SearchSubset( const C& x ) const noexcept
1678  {
1679  PCL_ASSERT_DIRECT_CONTAINER( C, T );
1680  return pcl::Search( m_data->begin, m_data->end, x.Begin(), x.End() );
1681  }
1682 
1685  template <class C>
1686  iterator SearchSubset( const C& x )
1687  {
1688  PCL_ASSERT_DIRECT_CONTAINER( C, T );
1689  EnsureUnique();
1690  return pcl::Search( m_data->begin, m_data->end, x.Begin(), x.End() );
1691  }
1692 
1695  template <class C, class BP>
1696  const_iterator SearchSubset( const C& x, BP p ) const noexcept( noexcept( p ) )
1697  {
1698  PCL_ASSERT_DIRECT_CONTAINER( C, T );
1699  return pcl::Search( m_data->begin, m_data->end, x.Begin(), x.End(), p );
1700  }
1701 
1704  template <class C, class BP>
1705  iterator SearchSubset( const C& x, BP p )
1706  {
1707  PCL_ASSERT_DIRECT_CONTAINER( C, T );
1708  EnsureUnique();
1709  return pcl::Search( m_data->begin, m_data->end, x.Begin(), x.End(), p );
1710  }
1711 
1714  template <class BI>
1715  const_iterator SearchLastSubset( BI i, BI j ) const noexcept
1716  {
1717  return pcl::SearchLast( m_data->begin, m_data->end, i, j );
1718  }
1719 
1722  template <class BI>
1724  {
1725  EnsureUnique();
1726  return pcl::SearchLast( m_data->begin, m_data->end, i, j );
1727  }
1728 
1731  template <class BI, class BP>
1732  const_iterator SearchLastSubset( BI i, BI j, BP p ) const noexcept( noexcept( p ) )
1733  {
1734  return pcl::SearchLast( m_data->begin, m_data->end, i, j, p );
1735  }
1736 
1739  template <class BI, class BP>
1740  iterator SearchLastSubset( BI i, BI j, BP p )
1741  {
1742  EnsureUnique();
1743  return pcl::SearchLast( m_data->begin, m_data->end, i, j, p );
1744  }
1745 
1748  template <class C>
1749  const_iterator SearchLastSubset( const C& x ) const noexcept
1750  {
1751  PCL_ASSERT_DIRECT_CONTAINER( C, T );
1752  return pcl::SearchLast( m_data->begin, m_data->end, x.Begin(), x.End() );
1753  }
1754 
1757  template <class C>
1759  {
1760  PCL_ASSERT_DIRECT_CONTAINER( C, T );
1761  EnsureUnique();
1762  return pcl::SearchLast( m_data->begin, m_data->end, x.Begin(), x.End() );
1763  }
1764 
1767  template <class C, class BP>
1768  const_iterator SearchLastSubset( const C& x, BP p ) const noexcept( noexcept( p ) )
1769  {
1770  PCL_ASSERT_DIRECT_CONTAINER( C, T );
1771  return pcl::SearchLast( m_data->begin, m_data->end, x.Begin(), x.End(), p );
1772  }
1773 
1776  template <class C, class BP>
1777  iterator SearchLastSubset( const C& x, BP p )
1778  {
1779  PCL_ASSERT_DIRECT_CONTAINER( C, T );
1780  EnsureUnique();
1781  return pcl::SearchLast( m_data->begin, m_data->end, x.Begin(), x.End(), p );
1782  }
1783 
1784 
1787  bool Contains( const T& v ) const noexcept
1788  {
1789  return Search( v ) != m_data->end;
1790  }
1791 
1794  template <class BP>
1795  bool Contains( const T& v, BP p ) const noexcept( noexcept( p ) )
1796  {
1797  return Search( v, p ) != m_data->end;
1798  }
1799 
1802  template <class FI>
1803  iterator ContainsSubset( FI i, FI j ) const noexcept
1804  {
1805  return SearchSubset( i, j ) != m_data->end;
1806  }
1807 
1810  template <class FI, class BP>
1811  iterator ContainsSubset( FI i, FI j, BP p ) const noexcept( noexcept( p ) )
1812  {
1813  return SearchSubset( i, j, p ) != m_data->end;
1814  }
1815 
1818  template <class C>
1819  iterator ContainsSubset( const C& c ) const noexcept
1820  {
1821  return SearchSubset( c ) != m_data->end;
1822  }
1823 
1826  template <class C, class BP>
1827  iterator ContainsSubset( const C& c, BP p ) const noexcept( noexcept( p ) )
1828  {
1829  return SearchSubset( c, p ) != m_data->end;
1830  }
1831 
1834  void Sort()
1835  {
1836  EnsureUnique();
1837  pcl::QuickSort( m_data->begin, m_data->end );
1838  }
1839 
1842  template <class BP>
1843  void Sort( BP p )
1844  {
1845  EnsureUnique();
1846  pcl::QuickSort( m_data->begin, m_data->end, p );
1847  }
1848 
1852  friend void Swap( Array& x1, Array& x2 ) noexcept
1853  {
1854  pcl::Swap( x1.m_data, x2.m_data );
1855  }
1856 
1873  template <class S, typename SP>
1874  S& ToSeparated( S& s, SP separator ) const
1875  {
1876  const_iterator i = m_data->begin;
1877  if ( i < m_data->end )
1878  {
1879  s.Append( S( *i ) );
1880  if ( ++i < m_data->end )
1881  do
1882  {
1883  s.Append( separator );
1884  s.Append( S( *i ) );
1885  }
1886  while ( ++i < m_data->end );
1887  }
1888  return s;
1889  }
1890 
1913  template <class S, typename SP, class AF>
1914  S& ToSeparated( S& s, SP separator, AF append ) const
1915  {
1916  const_iterator i = m_data->begin;
1917  if ( i < m_data->end )
1918  {
1919  append( s, S( *i ) );
1920  if ( ++i < m_data->end )
1921  {
1922  S p( separator );
1923  do
1924  {
1925  append( s, p );
1926  append( s, S( *i ) );
1927  }
1928  while ( ++i < m_data->end );
1929  }
1930  }
1931  return s;
1932  }
1933 
1942  template <class S>
1943  S& ToCommaSeparated( S& s ) const
1944  {
1945  return ToSeparated( s, ',' );
1946  }
1947 
1956  template <class S>
1957  S& ToSpaceSeparated( S& s ) const
1958  {
1959  return ToSeparated( s, ' ' );
1960  }
1961 
1970  template <class S>
1971  S& ToTabSeparated( S& s ) const
1972  {
1973  return ToSeparated( s, '\t' );
1974  }
1975 
1984  template <class S>
1985  S& ToNewLineSeparated( S& s ) const
1986  {
1987  return ToSeparated( s, '\n' );
1988  }
1989 
1998  uint64 Hash64( uint64 seed = 0 ) const
1999  {
2000  return pcl::Hash64( m_data->begin, m_data->Size(), seed );
2001  }
2002 
2011  uint32 Hash32( uint32 seed = 0 ) const noexcept
2012  {
2013  return pcl::Hash32( m_data->begin, m_data->Size(), seed );
2014  }
2015 
2020  uint64 Hash( uint64 seed = 0 ) const noexcept
2021  {
2022  return Hash64( seed );
2023  }
2024 
2025  // -------------------------------------------------------------------------
2026 
2027 private:
2028 
2034  struct Data : public ReferenceCounter
2035  {
2036  iterator begin = nullptr;
2037  iterator end = nullptr;
2038  iterator available = nullptr;
2039  allocator alloc;
2040 
2044  Data() = default;
2045 
2049  ~Data()
2050  {
2051  Deallocate();
2052  }
2053 
2057  size_type Size() const noexcept
2058  {
2059  return Length()*sizeof( T );
2060  }
2061 
2065  size_type Length() const noexcept
2066  {
2067  return end - begin;
2068  }
2069 
2073  size_type Capacity() const noexcept
2074  {
2075  return available - begin;
2076  }
2077 
2081  size_type Available() const noexcept
2082  {
2083  return available - end;
2084  }
2085 
2089  bool IsEmpty() const noexcept
2090  {
2091  return begin == end;
2092  }
2093 
2098  void Allocate( size_type n )
2099  {
2100  if ( n > 0 )
2101  {
2102  size_type m = alloc.PagedLength( n );
2103  begin = alloc.Allocate( m );
2104  end = begin + n;
2105  available = begin + m;
2106  }
2107  }
2108 
2112  void Deallocate()
2113  {
2114  PCL_CHECK( (begin == nullptr) ? end == nullptr : begin < end )
2115  if ( begin != nullptr )
2116  {
2117  Destroy( begin, end );
2118  alloc.Deallocate( begin );
2119  begin = end = available = nullptr;
2120  }
2121  }
2122 
2126  void Initialize( iterator __restrict__ i, iterator __restrict__ j )
2127  {
2128  for ( ; i < j; ++i )
2129  pcl::Construct( i, alloc );
2130  }
2131 
2136  void Initialize( iterator __restrict__ i, size_type n )
2137  {
2138  for ( ; n > 0; ++i, --n )
2139  pcl::Construct( i, alloc );
2140  }
2141 
2146  void Initialize( iterator __restrict__ i, iterator __restrict__ j, const T& v )
2147  {
2148  for ( ; i < j; ++i )
2149  pcl::Construct( i, v, alloc );
2150  }
2151 
2156  void Initialize( iterator __restrict__ i, size_type n, const T& v )
2157  {
2158  for ( ; n > 0; ++i, --n )
2159  pcl::Construct( i, v, alloc );
2160  }
2161 
2167  template <class FI>
2168  iterator Build( iterator __restrict__ i, FI p, FI q )
2169  {
2170  for ( ; p != q; ++i, ++p )
2171  pcl::Construct( i, *p, alloc );
2172  return i;
2173  }
2174 
2180  iterator UninitializedGrow( iterator __restrict__ i, size_type n )
2181  {
2182  if ( n > 0 )
2183  if ( Available() >= n )
2184  {
2185  if ( i < end )
2186  {
2187  iterator __restrict__ j1 = end;
2188  iterator __restrict__ j2 = end + n;
2189 
2190  for ( ;; )
2191  {
2192  pcl::Construct( --j2, *--j1, alloc );
2193 
2194  if ( j1 == i )
2195  {
2196  j2 = end;
2197  break;
2198  }
2199  else if ( j2 == end )
2200  {
2201  do
2202  *--j2 = *--j1;
2203  while ( j1 > i );
2204  break;
2205  }
2206  }
2207 
2208  Destroy( i, j2 );
2209  }
2210  end += n;
2211  }
2212  else
2213  {
2214  size_type m = alloc.PagedLength( Length()+n );
2215  iterator b = alloc.Allocate( m );
2216  iterator r = Build( b, begin, i );
2217  iterator e = Build( r+n, i, end );
2218 
2219  Deallocate();
2220  begin = b;
2221  end = e;
2222  available = b + m;
2223  i = r;
2224  }
2225 
2226  return i;
2227  }
2228 
2232  static void Destroy( iterator i, iterator j )
2233  {
2234  pcl::Destroy( i, j );
2235  }
2236  };
2237 
2242  Data* m_data = nullptr;
2243 
2248  void DetachFromData()
2249  {
2250  if ( !m_data->Detach() )
2251  delete m_data;
2252  }
2253 };
2254 
2255 // ----------------------------------------------------------------------------
2256 
2266 template <class T, class A> inline
2267 bool operator ==( const Array<T,A>& x1, const Array<T,A>& x2 ) noexcept
2268 {
2269  return x1.Length() == x2.Length() && pcl::Equal( x1.Begin(), x2.Begin(), x2.End() );
2270 }
2271 
2277 template <class T, class A> inline
2278 bool operator <( const Array<T,A>& x1, const Array<T,A>& x2 ) noexcept
2279 {
2280  return pcl::Compare( x1.Begin(), x1.End(), x2.Begin(), x2.End() ) < 0;
2281 }
2282 
2294 template <class T, class A, class V> inline
2295 Array<T,A>& operator <<( Array<T,A>& x, const V& v )
2296 {
2297  x.Append( T( v ) );
2298  return x;
2299 }
2300 
2308 template <class T, class A, class V> inline
2309 Array<T,A>& operator <<( Array<T,A>&& x, const V& v )
2310 {
2311  x.Append( T( v ) );
2312  return x;
2313 }
2314 
2320 template <class T, class A> inline
2321 Array<T,A>& operator <<( Array<T,A>& x1, const Array<T,A>& x2 )
2322 {
2323  x1.Append( x2 );
2324  return x1;
2325 }
2326 
2332 template <class T, class A> inline
2333 Array<T,A>& operator <<( Array<T,A>&& x1, const Array<T,A>& x2 )
2334 {
2335  x1.Append( x2 );
2336  return x1;
2337 }
2338 
2339 // ----------------------------------------------------------------------------
2340 
2341 } // pcl
2342 
2343 #endif // __PCL_Array_h
2344 
2345 // ----------------------------------------------------------------------------
2346 // EOF pcl/Array.h - Released 2024-06-18T15:48:54Z
Provides memory allocation for PCL containers.
Definition: Allocator.h:132
Generic dynamic array.
Definition: Array.h:100
iterator SearchLastSubset(BI i, BI j, BP p)
Definition: Array.h:1740
const_iterator MinItem() const noexcept
Definition: Array.h:1465
iterator SearchSubset(const C &x, BP p)
Definition: Array.h:1705
iterator ContainsSubset(const C &c, BP p) const noexcept(noexcept(p))
Definition: Array.h:1827
uint64 Hash64(uint64 seed=0) const
Definition: Array.h:1998
void Shrink(size_type n=1)
Definition: Array.h:845
iterator SearchLast(const T &v, BP p)
Definition: Array.h:1634
void Import(iterator i, iterator j)
Definition: Array.h:771
bool IsEmpty() const noexcept
Definition: Array.h:312
size_type LowerBound() const noexcept
Definition: Array.h:321
void Apply(F f) const noexcept(noexcept(f))
Definition: Array.h:1401
void Remove(iterator i, iterator j)
Definition: Array.h:1044
friend void Swap(Array &x1, Array &x2) noexcept
Definition: Array.h:1852
void ShiftRight(const T &v, size_type n=1)
Definition: Array.h:1564
void Sort()
Definition: Array.h:1834
Array(const Array &x)
Definition: Array.h:188
void Prepend(FI p, FI q)
Definition: Array.h:991
void Squeeze()
Definition: Array.h:1333
~Array()
Definition: Array.h:208
iterator Begin()
Definition: Array.h:426
iterator Grow(iterator i, size_type n=1)
Definition: Array.h:816
const_iterator SearchLastSubset(BI i, BI j) const noexcept
Definition: Array.h:1715
iterator Expand(size_type n=1)
Definition: Array.h:836
void Prepend(const T &v, size_type n=1)
Definition: Array.h:979
iterator MaxItem(BP p)
Definition: Array.h:1521
iterator MinItem()
Definition: Array.h:1472
const allocator & Allocator() const noexcept
Definition: Array.h:338
iterator SearchSubset(FI i, FI j, BP p)
Definition: Array.h:1668
const_iterator MinItem(BP p) const noexcept(noexcept(p))
Definition: Array.h:1481
void Transfer(Array &x)
Definition: Array.h:671
void Rotate(distance_type n)
Definition: Array.h:1537
const_iterator ConstEnd() const noexcept
Definition: Array.h:468
iterator At(size_type i)
Definition: Array.h:355
void UniquifyIterators(iterator &i, iterator &j)
Definition: Array.h:578
iterator ContainsSubset(const C &c) const noexcept
Definition: Array.h:1819
Array(size_type n)
Definition: Array.h:141
iterator SearchSubset(FI i, FI j)
Definition: Array.h:1651
uint64 Hash(uint64 seed=0) const noexcept
Definition: Array.h:2020
size_type Length() const noexcept
Definition: Array.h:266
Array(size_type n, const T &v)
Definition: Array.h:151
const_iterator SearchLastSubset(const C &x) const noexcept
Definition: Array.h:1749
iterator Replace(iterator i, iterator j, FI p, FI q)
Definition: Array.h:1264
void Resize(size_type n)
Definition: Array.h:862
void Add(const T &v, size_type n=1)
Definition: Array.h:1007
void Apply(F f)
Definition: Array.h:1390
bool IsValid() const noexcept
Definition: Array.h:304
void UniquifyIterator(iterator &i)
Definition: Array.h:558
bool IsAliasOf(const Array &x) const noexcept
Definition: Array.h:230
iterator end()
Definition: Array.h:611
const_iterator End() const noexcept
Definition: Array.h:460
bool IsUnique() const noexcept
Definition: Array.h:220
void Assign(const T &v, size_type n=1)
Definition: Array.h:698
iterator FirstThat(F f)
Definition: Array.h:1423
void Append(const T &v, size_type n=1)
Definition: Array.h:949
void Append(const Array &x)
Definition: Array.h:940
void ShiftLeft(const T &v, size_type n=1)
Definition: Array.h:1550
void Remove(const T &v)
Definition: Array.h:1109
iterator SearchLastSubset(const C &x)
Definition: Array.h:1758
uint32 Hash32(uint32 seed=0) const noexcept
Definition: Array.h:2011
void Sort(BP p)
Definition: Array.h:1843
void Add(const Array &x)
Definition: Array.h:999
const_iterator SearchSubset(const C &x) const noexcept
Definition: Array.h:1677
bool Contains(const T &v) const noexcept
Definition: Array.h:1787
size_type Count(const T &v) const noexcept
Definition: Array.h:1442
void Transfer(Array &&x)
Definition: Array.h:687
const_reverse_iterator ReverseEnd() const noexcept
Definition: Array.h:531
iterator Replace(iterator i, iterator j, const Array &x)
Definition: Array.h:1199
Array()
Definition: Array.h:132
void SetAllocator(const allocator &a)
Definition: Array.h:346
Array(FI i, FI j)
Definition: Array.h:163
iterator End()
Definition: Array.h:451
iterator SearchLast(const T &v)
Definition: Array.h:1617
void Remove(const T &v, BP p)
Definition: Array.h:1138
iterator ContainsSubset(FI i, FI j, BP p) const noexcept(noexcept(p))
Definition: Array.h:1811
const_reverse_iterator ConstReverseBegin() const noexcept
Definition: Array.h:504
void Assign(const Array &x)
Definition: Array.h:646
const_iterator Begin() const noexcept
Definition: Array.h:435
void Assign(FI i, FI j)
Definition: Array.h:733
Array(std::initializer_list< T1 > l)
Definition: Array.h:180
void Prepend(const Array &x)
Definition: Array.h:970
const_iterator SearchLastSubset(BI i, BI j, BP p) const noexcept(noexcept(p))
Definition: Array.h:1732
const_iterator MaxItem() const noexcept
Definition: Array.h:1497
const_iterator LastThat(F f) const noexcept(noexcept(f))
Definition: Array.h:1435
bool Contains(const T &v, BP p) const noexcept(noexcept(p))
Definition: Array.h:1795
void RemoveLast(size_type n=1)
Definition: Array.h:1085
size_type UpperBound() const noexcept
Definition: Array.h:330
const_iterator SearchSubset(FI i, FI j) const noexcept
Definition: Array.h:1643
iterator SearchSubset(const C &x)
Definition: Array.h:1686
iterator Replace(iterator i, iterator j, const T &v, size_type n=1)
Definition: Array.h:1221
const_iterator SearchSubset(const C &x, BP p) const noexcept(noexcept(p))
Definition: Array.h:1696
size_type Count(const T &v, BP p) const noexcept(noexcept(p))
Definition: Array.h:1450
const_iterator begin() const noexcept
Definition: Array.h:603
const_reverse_iterator ConstReverseEnd() const noexcept
Definition: Array.h:544
iterator Insert(iterator i, FI p, FI q)
Definition: Array.h:925
void Clear()
Definition: Array.h:1173
iterator Search(const T &v, BP p)
Definition: Array.h:1602
reverse_iterator ReverseEnd()
Definition: Array.h:517
const_iterator SearchSubset(FI i, FI j, BP p) const noexcept(noexcept(p))
Definition: Array.h:1660
iterator Insert(iterator i, const Array &x)
Definition: Array.h:882
void Reverse()
Definition: Array.h:1529
iterator Insert(iterator i, const T &v, size_type n=1)
Definition: Array.h:901
void EnsureUnique()
Definition: Array.h:242
const_iterator At(size_type i) const noexcept
Definition: Array.h:365
iterator ContainsSubset(FI i, FI j) const noexcept
Definition: Array.h:1803
A block_allocator
Definition: Array.h:105
void Append(FI p, FI q)
Definition: Array.h:961
const_iterator Search(const T &v) const noexcept
Definition: Array.h:1578
reverse_iterator ReverseBegin()
Definition: Array.h:479
size_type Capacity() const noexcept
Definition: Array.h:275
const_iterator end() const noexcept
Definition: Array.h:619
const_iterator FirstThat(F f) const noexcept(noexcept(f))
Definition: Array.h:1412
Array(Array &&x)
Definition: Array.h:198
void Truncate(iterator i)
Definition: Array.h:1100
iterator MaxItem()
Definition: Array.h:1504
iterator SearchLastSubset(const C &x, BP p)
Definition: Array.h:1777
const_iterator Search(const T &v, BP p) const noexcept(noexcept(p))
Definition: Array.h:1594
void Fill(const T &v)
Definition: Array.h:1362
iterator Release()
Definition: Array.h:798
void SecureFill(const T &v)
Definition: Array.h:1380
size_type Size() const noexcept
Definition: Array.h:258
const_iterator MaxItem(BP p) const noexcept(noexcept(p))
Definition: Array.h:1513
void Reserve(size_type n)
Definition: Array.h:1295
const_iterator ConstBegin() const noexcept
Definition: Array.h:443
size_type CountIf(UP p) const noexcept(noexcept(p))
Definition: Array.h:1458
T * iterator
Definition: Array.h:113
iterator MinItem(BP p)
Definition: Array.h:1489
const T * const_iterator
Definition: Array.h:117
const_iterator SearchLastSubset(const C &x, BP p) const noexcept(noexcept(p))
Definition: Array.h:1768
void Add(FI p, FI q)
Definition: Array.h:1016
const_iterator SearchLast(const T &v) const noexcept
Definition: Array.h:1610
iterator begin()
Definition: Array.h:595
void Remove(iterator i, size_type n=1)
Definition: Array.h:1030
const_iterator SearchLast(const T &v, BP p) const noexcept(noexcept(p))
Definition: Array.h:1626
const_reverse_iterator ReverseBegin() const noexcept
Definition: Array.h:492
iterator SearchLastSubset(BI i, BI j)
Definition: Array.h:1723
iterator Search(const T &v)
Definition: Array.h:1585
void RemoveFirst(size_type n=1)
Definition: Array.h:1071
size_type Available() const noexcept
Definition: Array.h:286
iterator MutableIterator(const_iterator i)
Definition: Array.h:381
Root base class of all PCL containers of objects.
Definition: Container.h:78
Thread-safe reference counter for copy-on-write data structures.
Reverse random access iterator.
Definition: Iterator.h:420
Array< T, A > & operator<<(Array< T, A > &x, const V &v)
Definition: Array.h:2295
bool operator==(const Array< T, A > &x1, const Array< T, A > &x2) noexcept
Definition: Array.h:2267
bool operator<(const Array< T, A > &x1, const Array< T, A > &x2) noexcept
Definition: Array.h:2278
Complex< T1 > operator*(const Complex< T1 > &c1, const Complex< T2 > &c2) noexcept
Definition: Complex.h:548
uint64 Hash64(const void *data, size_type size, uint64 seed=0) noexcept
Definition: Math.h:4750
uint32 Hash32(const void *data, size_type size, uint32 seed=0) noexcept
Definition: Math.h:4904
void Rotate(T &x, T &y, T1 sa, T1 ca, T2 xc, T2 yc) noexcept
Definition: Math.h:2024
void Construct(T *p, A &a)
Definition: Allocator.h:247
void Destroy(T *p)
Definition: Allocator.h:277
void Swap(GenericPoint< T > &p1, GenericPoint< T > &p2) noexcept
Definition: Point.h:1459
unsigned long long uint64
Definition: Defs.h:682
unsigned int uint32
Definition: Defs.h:666
FI LinearSearch(FI i, FI j, const T &v) noexcept
Definition: Search.h:91
BI1 SearchLast(BI1 i1, BI1 j1, FI2 i2, FI2 j2) noexcept
Definition: Search.h:449
BI LinearSearchLast(BI i, BI j, const T &v) noexcept
Definition: Search.h:129
FI1 Search(FI1 i1, FI1 j1, FI2 i2, FI2 j2) noexcept
Definition: Search.h:397
ptrdiff_t distance_type
Definition: Defs.h:615
size_t size_type
Definition: Defs.h:609
void QuickSort(RI i, RI j)
Definition: Sort.h:236
size_type CountIf(FI i, FI j, UP p) noexcept(noexcept(p))
Definition: Utility.h:423
constexpr const T & Min(const T &a, const T &b) noexcept
Definition: Utility.h:90
BI LastThat(BI i, BI j, UP p) noexcept(noexcept(p))
Definition: Utility.h:350
size_type Count(FI i, FI j, const T &v) noexcept
Definition: Utility.h:384
FI MinItem(FI i, FI j) noexcept
Definition: Utility.h:441
bool Equal(FI1 i1, FI2 i2, FI2 j2) noexcept
Definition: Utility.h:592
int Compare(FI1 i1, FI1 j1, FI2 i2, FI2 j2) noexcept
Definition: Utility.h:639
constexpr const T & Range(const T &x, const T &a, const T &b) noexcept
Definition: Utility.h:190
constexpr const T & Max(const T &a, const T &b) noexcept
Definition: Utility.h:119
FI MaxItem(FI i, FI j) noexcept
Definition: Utility.h:479
void Apply(FI i, FI j, F f) noexcept(noexcept(f))
Definition: Utility.h:249
FI FirstThat(FI i, FI j, UP p) noexcept(noexcept(p))
Definition: Utility.h:316
PCL root namespace.
Definition: AbstractImage.h:77
distance_type Distance(FI i, FI j)
Definition: Iterator.h:161