PCL
Array.h
Go to the documentation of this file.
1 // ____ ______ __
2 // / __ \ / ____// /
3 // / /_/ // / / /
4 // / ____// /___ / /___ PixInsight Class Library
5 // /_/ \____//_____/ PCL 2.8.4
6 // ----------------------------------------------------------------------------
7 // pcl/Array.h - Released 2024-12-23T11:32:56Z
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 
106 
110 
114 
117  using block_allocator = A;
118 
122 
125  using iterator = T*;
126 
129  using const_iterator = const T*;
130 
134 
138 
139  // -------------------------------------------------------------------------
140 
145  {
146  m_data = new Data;
147  }
148 
152  explicit
154  {
155  m_data = new Data;
156  m_data->Allocate( n );
157  m_data->Initialize( m_data->begin, m_data->end );
158  }
159 
163  Array( size_type n, const T& v )
164  {
165  m_data = new Data;
166  m_data->Allocate( n );
167  m_data->Initialize( m_data->begin, m_data->end, v );
168  }
169 
174  template <class FI>
175  Array( FI i, FI j )
176  {
177  m_data = new Data;
178  m_data->Allocate( size_type( pcl::Distance( i, j ) ) );
179  if ( m_data->begin != nullptr )
180  m_data->Build( m_data->begin, i, j );
181  }
182 
191  template <typename T1>
192  Array( std::initializer_list<T1> l )
193  : Array( l.begin(), l.end() )
194  {
195  }
196 
200  Array( const Array& x )
201  : m_data( x.m_data )
202  {
203  if ( m_data != nullptr )
204  m_data->Attach();
205  }
206 
210  Array( Array&& x )
211  : m_data( x.m_data )
212  {
213  x.m_data = nullptr;
214  }
215 
221  {
222  if ( m_data != nullptr )
223  {
224  DetachFromData();
225  m_data = nullptr;
226  }
227  }
228 
232  bool IsUnique() const noexcept
233  {
234  return m_data->IsUnique();
235  }
236 
242  bool IsAliasOf( const Array& x ) const noexcept
243  {
244  return m_data == x.m_data;
245  }
246 
255  {
256  if ( !IsUnique() )
257  {
258  Data* newData = new Data;
259  newData->Allocate( Length() );
260  newData->Build( newData->begin, m_data->begin, m_data->end );
261  DetachFromData();
262  m_data = newData;
263  }
264  }
265 
270  size_type Size() const noexcept
271  {
272  return m_data->Size();
273  }
274 
278  size_type Length() const noexcept
279  {
280  return m_data->Length();
281  }
282 
287  size_type Capacity() const noexcept
288  {
289  return m_data->Capacity();
290  }
291 
298  size_type Available() const noexcept
299  {
300  return m_data->Available();
301  }
302 
316  bool IsValid() const noexcept
317  {
318  return m_data != nullptr;
319  }
320 
324  bool IsEmpty() const noexcept
325  {
326  return m_data->IsEmpty();
327  }
328 
333  size_type LowerBound() const noexcept
334  {
335  return 0;
336  }
337 
342  size_type UpperBound() const noexcept
343  {
344  return Length()-1;
345  }
346 
350  const allocator& Allocator() const noexcept
351  {
352  return m_data->alloc;
353  }
354 
358  void SetAllocator( const allocator& a )
359  {
360  EnsureUnique();
361  m_data->alloc = a;
362  }
363 
368  {
369  PCL_PRECONDITION( !IsEmpty() && i < Length() )
370  EnsureUnique();
371  return m_data->begin + i;
372  }
373 
377  const_iterator At( size_type i ) const noexcept
378  {
379  PCL_PRECONDITION( !IsEmpty() && i < Length() )
380  return m_data->begin + i;
381  }
382 
394  {
395  return At( i - m_data->begin );
396  }
397 
402  T& operator []( size_type i )
403  {
404  return *At( i );
405  }
406 
411  const T& operator []( size_type i ) const noexcept
412  {
413  return *At( i );
414  }
415 
420  {
421  PCL_PRECONDITION( m_data->begin != nullptr )
422  EnsureUnique();
423  return *m_data->begin;
424  }
425 
429  const T& operator *() const noexcept
430  {
431  PCL_PRECONDITION( m_data->begin != nullptr )
432  return *m_data->begin;
433  }
434 
439  {
440  EnsureUnique();
441  return m_data->begin;
442  }
443 
447  const_iterator Begin() const noexcept
448  {
449  return m_data->begin;
450  }
451 
455  const_iterator ConstBegin() const noexcept
456  {
457  return m_data->begin;
458  }
459 
464  {
465  EnsureUnique();
466  return m_data->end;
467  }
468 
472  const_iterator End() const noexcept
473  {
474  return m_data->end;
475  }
476 
480  const_iterator ConstEnd() const noexcept
481  {
482  return m_data->end;
483  }
484 
492  {
493  PCL_PRECONDITION( m_data->end != nullptr )
494  EnsureUnique();
495  return m_data->end - 1;
496  }
497 
505  {
506  PCL_PRECONDITION( m_data->end != nullptr )
507  return m_data->end - 1;
508  }
509 
517  {
518  PCL_PRECONDITION( m_data->end != nullptr )
519  return m_data->end - 1;
520  }
521 
530  {
531  PCL_PRECONDITION( m_data->begin != nullptr )
532  EnsureUnique();
533  return m_data->begin - 1;
534  }
535 
544  {
545  PCL_PRECONDITION( m_data->begin != nullptr )
546  return m_data->begin - 1;
547  }
548 
557  {
558  PCL_PRECONDITION( m_data->begin != nullptr )
559  return m_data->begin - 1;
560  }
561 
571  {
572  PCL_PRECONDITION( i >= m_data->begin && i <= m_data->end )
573  if ( !IsUnique() )
574  {
575  distance_type d = i - m_data->begin;
576  EnsureUnique();
577  i = m_data->begin + d;
578  }
579  }
580 
591  {
592  PCL_PRECONDITION( i >= m_data->begin && i <= m_data->end )
593  PCL_PRECONDITION( j >= m_data->begin && j <= m_data->end )
594  if ( !IsUnique() )
595  {
596  distance_type d = i - m_data->begin;
597  distance_type r = j - i;
598  EnsureUnique();
599  j = (i = m_data->begin + d) + r;
600  }
601  }
602 
603 #ifndef __PCL_NO_STL_COMPATIBLE_ITERATORS
608  {
609  return Begin();
610  }
611 
615  const_iterator begin() const noexcept
616  {
617  return Begin();
618  }
619 
624  {
625  return End();
626  }
627 
631  const_iterator end() const noexcept
632  {
633  return End();
634  }
635 #endif // !__PCL_NO_STL_COMPATIBLE_ITERATORS
636 
643  Array& operator =( const Array& x )
644  {
645  Assign( x );
646  return *this;
647  }
648 
658  void Assign( const Array& x )
659  {
660  x.m_data->Attach();
661  DetachFromData();
662  m_data = x.m_data;
663  }
664 
668  Array& operator =( Array&& x )
669  {
670  Transfer( x );
671  return *this;
672  }
673 
683  void Transfer( Array& x )
684  {
685  if ( &x != this )
686  {
687  DetachFromData();
688  m_data = x.m_data;
689  x.m_data = nullptr;
690  }
691  }
692 
702  void Transfer( Array&& x )
703  {
704  if ( &x != this )
705  {
706  DetachFromData();
707  m_data = x.m_data;
708  x.m_data = nullptr;
709  }
710  }
711 
716  void Assign( const T& v, size_type n = 1 )
717  {
718  if ( n > 0 )
719  {
720  if ( !IsUnique() )
721  {
722  Data* newData = new Data;
723  DetachFromData();
724  m_data = newData;
725  }
726 
727  if ( Capacity() < n )
728  {
729  m_data->Deallocate();
730  m_data->Allocate( n );
731  }
732  else
733  {
734  m_data->Destroy( m_data->begin, m_data->end );
735  m_data->end = m_data->begin + n;
736  }
737 
738  m_data->Initialize( m_data->begin, m_data->end, v );
739  }
740  else
741  Clear();
742  }
743 
750  template <class FI>
751  void Assign( FI i, FI j )
752  {
753  size_type n = size_type( pcl::Distance( i, j ) );
754  if ( n > 0 )
755  {
756  if ( !IsUnique() )
757  {
758  Data* newData = new Data;
759  DetachFromData();
760  m_data = newData;
761  }
762 
763  if ( Capacity() < n )
764  {
765  m_data->Deallocate();
766  m_data->Allocate( n );
767  }
768  else
769  {
770  m_data->Destroy( m_data->begin, m_data->end );
771  m_data->end = m_data->begin + n;
772  }
773 
774  m_data->Build( m_data->begin, i, j );
775  }
776  else
777  Clear();
778  }
779 
789  void Import( iterator i, iterator j )
790  {
791  if ( i >= m_data->available || j <= m_data->begin )
792  {
793  Clear();
794  size_type n = size_type( pcl::Distance( i, j ) );
795  if ( n > 0 )
796  {
797  EnsureUnique();
798  m_data->begin = i;
799  m_data->end = m_data->available = j;
800  }
801  }
802  }
803 
817  {
818  EnsureUnique();
819  iterator b = m_data->begin;
820  m_data->begin = m_data->end = m_data->available = nullptr;
821  return b;
822  }
823 
835  {
836  i = pcl::Range( i, m_data->begin, m_data->end );
837  if ( n > 0 )
838  {
839  UniquifyIterator( i );
840  m_data->Initialize( i = m_data->UninitializedGrow( i, n ), n );
841  }
842  return i;
843  }
844 
855  {
856  return Grow( m_data->end, n );
857  }
858 
863  void Shrink( size_type n = 1 )
864  {
865  RemoveLast( n );
866  }
867 
880  void Resize( size_type n )
881  {
882  size_type l = m_data->Length();
883  if ( n > l )
884  Expand( n - l );
885  else
886  Shrink( l - n );
887  }
888 
900  iterator Insert( iterator i, const Array& x )
901  {
902  if ( &x != this )
903  return Insert( i, x.Begin(), x.End() );
904  Array t( *this );
905  t.EnsureUnique();
906  return Insert( i, t.m_data->begin, t.m_data->end );
907  }
908 
919  iterator Insert( iterator i, const T& v, size_type n = 1 )
920  {
921  i = pcl::Range( i, m_data->begin, m_data->end );
922  if ( n > 0 )
923  {
924  UniquifyIterator( i );
925  m_data->Initialize( i = m_data->UninitializedGrow( i, n ), n, v );
926  }
927  return i;
928  }
929 
942  template <class FI>
943  iterator Insert( iterator i, FI p, FI q )
944  {
945  i = pcl::Range( i, m_data->begin, m_data->end );
946  size_type n = size_type( pcl::Distance( p, q ) );
947  if ( n > 0 )
948  {
949  UniquifyIterator( i );
950  m_data->Build( i = m_data->UninitializedGrow( i, n ), p, q );
951  }
952  return i;
953  }
954 
958  void Append( const Array& x )
959  {
960  Insert( m_data->end, x );
961  }
962 
967  void Append( const T& v, size_type n = 1 )
968  {
969  Insert( m_data->end, v, n );
970  }
971 
978  template <class FI>
979  void Append( FI p, FI q )
980  {
981  Insert( m_data->end, p, q );
982  }
983 
988  void Prepend( const Array& x )
989  {
990  Insert( m_data->begin, x );
991  }
992 
997  void Prepend( const T& v, size_type n = 1 )
998  {
999  Insert( m_data->begin, v, n );
1000  }
1001 
1008  template <class FI>
1009  void Prepend( FI p, FI q )
1010  {
1011  Insert( m_data->begin, p, q );
1012  }
1013 
1017  void Add( const Array& x )
1018  {
1019  Append( x );
1020  }
1021 
1025  void Add( const T& v, size_type n = 1 )
1026  {
1027  Append( v, n );
1028  }
1029 
1033  template <class FI>
1034  void Add( FI p, FI q )
1035  {
1036  Append( p, q );
1037  }
1038 
1048  void Remove( iterator i, size_type n = 1 )
1049  {
1050  Remove( i, i+n );
1051  }
1052 
1062  void Remove( iterator i, iterator j )
1063  {
1064  if ( i < m_data->end )
1065  if ( i < j )
1066  {
1067  i = pcl::Max( m_data->begin, i );
1068  j = pcl::Min( j, m_data->end );
1069  if ( i > m_data->begin || j < m_data->end )
1070  {
1071  UniquifyIterators( i, j );
1072  m_data->Destroy( j = pcl::Copy( i, j, m_data->end ), m_data->end );
1073  m_data->end = j;
1074  }
1075  else
1076  Clear();
1077  }
1078  }
1079 
1089  void RemoveFirst( size_type n = 1 )
1090  {
1091  Remove( m_data->begin, m_data->begin + pcl::Min( n, m_data->Length() ) );
1092  }
1093 
1103  void RemoveLast( size_type n = 1 )
1104  {
1105  Remove( m_data->end - pcl::Min( n, m_data->Length() ), m_data->end );
1106  }
1107 
1118  void Truncate( iterator i )
1119  {
1120  Remove( i, m_data->end );
1121  }
1122 
1127  void Remove( const T& v )
1128  {
1129  Array a;
1130  for ( iterator i = m_data->begin, j = i; ; ++j )
1131  {
1132  if ( j == m_data->end )
1133  {
1134  if ( i != m_data->begin )
1135  {
1136  a.Add( i, j );
1137  Transfer( a );
1138  }
1139  break;
1140  }
1141 
1142  if ( *j == v )
1143  {
1144  a.Add( i, j );
1145  i = j;
1146  ++i;
1147  }
1148  }
1149  }
1150 
1155  template <class BP>
1156  void Remove( const T& v, BP p )
1157  {
1158  Array a;
1159  for ( iterator i = m_data->begin, j = i; ; ++j )
1160  {
1161  if ( j == m_data->end )
1162  {
1163  if ( i != m_data->begin )
1164  {
1165  a.Add( i, j );
1166  Transfer( a );
1167  }
1168  break;
1169  }
1170 
1171  if ( p( *j, v ) )
1172  {
1173  a.Add( i, j );
1174  i = j;
1175  ++i;
1176  }
1177  }
1178  }
1179 
1191  void Clear()
1192  {
1193  if ( !IsEmpty() )
1194  if ( IsUnique() )
1195  m_data->Deallocate();
1196  else
1197  {
1198  Data* newData = new Data;
1199  DetachFromData();
1200  m_data = newData;
1201  }
1202  }
1203 
1218  {
1219  if ( &x != this )
1220  return Replace( i, j, x.Begin(), x.End() );
1221  Array t( *this );
1222  t.EnsureUnique();
1223  return Replace( i, j, t.ConstBegin(), t.ConstEnd() );
1224  }
1225 
1239  iterator Replace( iterator i, iterator j, const T& v, size_type n = 1 )
1240  {
1241  i = pcl::Range( i, m_data->begin, m_data->end );
1242  j = pcl::Range( j, m_data->begin, m_data->end );
1243  if ( i < j )
1244  if ( i < m_data->end )
1245  {
1246  UniquifyIterators( i, j );
1247  size_type d = size_type( j - i );
1248  if ( d < n )
1249  {
1250  m_data->Destroy( i, j );
1251  m_data->Initialize( i = m_data->UninitializedGrow( i, n-d ), n, v );
1252  }
1253  else
1254  {
1255  iterator k = i + n;
1256  pcl::Fill( i, k, v );
1257  Remove( k, j );
1258  if ( m_data->begin == nullptr )
1259  i = nullptr;
1260  }
1261  }
1262  return i;
1263  }
1264 
1281  template <class FI>
1282  iterator Replace( iterator i, iterator j, FI p, FI q )
1283  {
1284  i = pcl::Range( i, m_data->begin, m_data->end );
1285  j = pcl::Range( j, m_data->begin, m_data->end );
1286  if ( i < j )
1287  if ( i < m_data->end )
1288  {
1289  UniquifyIterators( i, j );
1290  size_type d = size_type( j - i );
1291  size_type n = size_type( pcl::Distance( p, q ) );
1292  if ( d < n )
1293  {
1294  m_data->Destroy( i, j );
1295  m_data->Build( i = m_data->UninitializedGrow( i, n-d ), p, q );
1296  }
1297  else
1298  {
1299  Remove( pcl::Move( i, p, q ), j );
1300  if ( m_data->begin == nullptr )
1301  i = nullptr;
1302  }
1303  }
1304  return i;
1305  }
1306 
1313  void Reserve( size_type n )
1314  {
1315  if ( n > 0 )
1316  if ( IsUnique() )
1317  {
1318  if ( Capacity() < n )
1319  {
1320  iterator b = m_data->alloc.Allocate( n );
1321  iterator e = m_data->Build( b, m_data->begin, m_data->end );
1322  m_data->Deallocate();
1323  m_data->begin = b;
1324  m_data->end = e;
1325  m_data->available = m_data->begin + n;
1326  }
1327  }
1328  else
1329  {
1330  Data* newData = new Data;
1331  newData->begin = newData->alloc.Allocate( n = pcl::Max( Length(), n ) );
1332  newData->end = newData->Build( newData->begin, m_data->begin, m_data->end );
1333  newData->available = newData->begin + n;
1334  DetachFromData();
1335  m_data = newData;
1336  }
1337  }
1338 
1351  void Squeeze()
1352  {
1353  if ( IsUnique() )
1354  {
1355  if ( Available() > 0 )
1356  {
1357  iterator b = m_data->alloc.Allocate( Length() );
1358  iterator e = m_data->Build( b, m_data->begin, m_data->end );
1359  m_data->Deallocate();
1360  m_data->begin = b;
1361  m_data->end = m_data->available = e;
1362  }
1363  }
1364  else
1365  {
1366  Data* newData = new Data;
1367  if ( !IsEmpty() )
1368  {
1369  newData->begin = newData->alloc.Allocate( Length() );
1370  newData->available = newData->end = newData->Build( newData->begin, m_data->begin, m_data->end );
1371  }
1372  DetachFromData();
1373  m_data = newData;
1374  }
1375  }
1376 
1380  void Fill( const T& v )
1381  {
1382  EnsureUnique();
1383  pcl::Fill( m_data->begin, m_data->end, v );
1384  }
1385 
1398  void SecureFill( const T& v )
1399  {
1400  pcl::Fill( m_data->begin, m_data->end, v );
1401  }
1402 
1407  template <class F>
1408  void Apply( F f )
1409  {
1410  EnsureUnique();
1411  pcl::Apply( m_data->begin, m_data->end, f );
1412  }
1413 
1418  template <class F>
1419  void Apply( F f ) const noexcept( noexcept( f ) )
1420  {
1421  pcl::Apply( m_data->begin, m_data->end, f );
1422  }
1423 
1429  template <class F>
1430  const_iterator FirstThat( F f ) const noexcept( noexcept( f ) )
1431  {
1432  return pcl::FirstThat( m_data->begin, m_data->end, f );
1433  }
1434 
1440  template <class F>
1442  {
1443  EnsureUnique();
1444  return pcl::FirstThat( m_data->begin, m_data->end, f );
1445  }
1446 
1452  template <class F>
1453  const_iterator LastThat( F f ) const noexcept( noexcept( f ) )
1454  {
1455  return pcl::LastThat( m_data->begin, m_data->end, f );
1456  }
1457 
1460  size_type Count( const T& v ) const noexcept
1461  {
1462  return pcl::Count( m_data->begin, m_data->end, v );
1463  }
1464 
1467  template <class BP>
1468  size_type Count( const T& v, BP p ) const noexcept( noexcept( p ) )
1469  {
1470  return pcl::Count( m_data->begin, m_data->end, v, p );
1471  }
1472 
1475  template <class UP>
1476  size_type CountIf( UP p ) const noexcept( noexcept( p ) )
1477  {
1478  return pcl::CountIf( m_data->begin, m_data->end, p );
1479  }
1480 
1483  const_iterator MinItem() const noexcept
1484  {
1485  return pcl::MinItem( m_data->begin, m_data->end );
1486  }
1487 
1491  {
1492  EnsureUnique();
1493  return pcl::MinItem( m_data->begin, m_data->end );
1494  }
1495 
1498  template <class BP>
1499  const_iterator MinItem( BP p ) const noexcept( noexcept( p ) )
1500  {
1501  return pcl::MinItem( m_data->begin, m_data->end, p );
1502  }
1503 
1506  template <class BP>
1508  {
1509  EnsureUnique();
1510  return pcl::MinItem( m_data->begin, m_data->end, p );
1511  }
1512 
1515  const_iterator MaxItem() const noexcept
1516  {
1517  return pcl::MaxItem( m_data->begin, m_data->end );
1518  }
1519 
1523  {
1524  EnsureUnique();
1525  return pcl::MaxItem( m_data->begin, m_data->end );
1526  }
1527 
1530  template <class BP>
1531  const_iterator MaxItem( BP p ) const noexcept( noexcept( p ) )
1532  {
1533  return pcl::MaxItem( m_data->begin, m_data->end, p );
1534  }
1535 
1538  template <class BP>
1540  {
1541  EnsureUnique();
1542  return pcl::MaxItem( m_data->begin, m_data->end, p );
1543  }
1544 
1547  void Reverse()
1548  {
1549  EnsureUnique();
1550  pcl::Reverse( m_data->begin, m_data->end );
1551  }
1552 
1556  {
1557  if ( Length() > 1 && n != 0 )
1558  {
1559  EnsureUnique();
1560  if ( (n %= Length()) < 0 )
1561  n += Length();
1562  pcl::Rotate( m_data->begin, m_data->begin+n, m_data->end );
1563  }
1564  }
1565 
1568  void ShiftLeft( const T& v, size_type n = 1 )
1569  {
1570  if ( !IsEmpty() && n > 0 )
1571  {
1572  EnsureUnique();
1573  if ( n >= Length() )
1574  pcl::Fill( m_data->begin, m_data->end, v );
1575  else
1576  pcl::ShiftLeft( m_data->begin, m_data->begin+n, m_data->end, v );
1577  }
1578  }
1579 
1582  void ShiftRight( const T& v, size_type n = 1 )
1583  {
1584  if ( !IsEmpty() && n > 0 )
1585  {
1586  EnsureUnique();
1587  if ( n >= Length() )
1588  pcl::Fill( m_data->begin, m_data->end, v );
1589  else
1590  pcl::ShiftRight( m_data->begin, m_data->end-n, m_data->end, v );
1591  }
1592  }
1593 
1596  const_iterator Search( const T& v ) const noexcept
1597  {
1598  return pcl::LinearSearch( m_data->begin, m_data->end, v );
1599  }
1600 
1603  iterator Search( const T& v )
1604  {
1605  EnsureUnique();
1606  return pcl::LinearSearch( m_data->begin, m_data->end, v );
1607  }
1608 
1611  template <class BP>
1612  const_iterator Search( const T& v, BP p ) const noexcept( noexcept( p ) )
1613  {
1614  return pcl::LinearSearch( m_data->begin, m_data->end, v, p );
1615  }
1616 
1619  template <class BP>
1620  iterator Search( const T& v, BP p )
1621  {
1622  EnsureUnique();
1623  return pcl::LinearSearch( m_data->begin, m_data->end, v, p );
1624  }
1625 
1628  const_iterator SearchLast( const T& v ) const noexcept
1629  {
1630  return pcl::LinearSearchLast( m_data->begin, m_data->end, v );
1631  }
1632 
1635  iterator SearchLast( const T& v )
1636  {
1637  EnsureUnique();
1638  return pcl::LinearSearchLast( m_data->begin, m_data->end, v );
1639  }
1640 
1643  template <class BP>
1644  const_iterator SearchLast( const T& v, BP p ) const noexcept( noexcept( p ) )
1645  {
1646  return pcl::LinearSearchLast( m_data->begin, m_data->end, v, p );
1647  }
1648 
1651  template <class BP>
1652  iterator SearchLast( const T& v, BP p )
1653  {
1654  EnsureUnique();
1655  return pcl::LinearSearchLast( m_data->begin, m_data->end, v, p );
1656  }
1657 
1660  template <class FI>
1661  const_iterator SearchSubset( FI i, FI j ) const noexcept
1662  {
1663  return pcl::Search( m_data->begin, m_data->end, i, j );
1664  }
1665 
1668  template <class FI>
1669  iterator SearchSubset( FI i, FI j )
1670  {
1671  EnsureUnique();
1672  return pcl::Search( m_data->begin, m_data->end, i, j );
1673  }
1674 
1677  template <class FI, class BP>
1678  const_iterator SearchSubset( FI i, FI j, BP p ) const noexcept( noexcept( p ) )
1679  {
1680  return pcl::Search( m_data->begin, m_data->end, i, j, p );
1681  }
1682 
1685  template <class FI, class BP>
1686  iterator SearchSubset( FI i, FI j, BP p )
1687  {
1688  EnsureUnique();
1689  return pcl::Search( m_data->begin, m_data->end, i, j, p );
1690  }
1691 
1694  template <class C>
1695  const_iterator SearchSubset( const C& x ) const noexcept
1696  {
1697  PCL_ASSERT_DIRECT_CONTAINER( C, T );
1698  return pcl::Search( m_data->begin, m_data->end, x.Begin(), x.End() );
1699  }
1700 
1703  template <class C>
1704  iterator SearchSubset( const C& x )
1705  {
1706  PCL_ASSERT_DIRECT_CONTAINER( C, T );
1707  EnsureUnique();
1708  return pcl::Search( m_data->begin, m_data->end, x.Begin(), x.End() );
1709  }
1710 
1713  template <class C, class BP>
1714  const_iterator SearchSubset( const C& x, BP p ) const noexcept( noexcept( p ) )
1715  {
1716  PCL_ASSERT_DIRECT_CONTAINER( C, T );
1717  return pcl::Search( m_data->begin, m_data->end, x.Begin(), x.End(), p );
1718  }
1719 
1722  template <class C, class BP>
1723  iterator SearchSubset( const C& x, BP p )
1724  {
1725  PCL_ASSERT_DIRECT_CONTAINER( C, T );
1726  EnsureUnique();
1727  return pcl::Search( m_data->begin, m_data->end, x.Begin(), x.End(), p );
1728  }
1729 
1732  template <class BI>
1733  const_iterator SearchLastSubset( BI i, BI j ) const noexcept
1734  {
1735  return pcl::SearchLast( m_data->begin, m_data->end, i, j );
1736  }
1737 
1740  template <class BI>
1742  {
1743  EnsureUnique();
1744  return pcl::SearchLast( m_data->begin, m_data->end, i, j );
1745  }
1746 
1749  template <class BI, class BP>
1750  const_iterator SearchLastSubset( BI i, BI j, BP p ) const noexcept( noexcept( p ) )
1751  {
1752  return pcl::SearchLast( m_data->begin, m_data->end, i, j, p );
1753  }
1754 
1757  template <class BI, class BP>
1758  iterator SearchLastSubset( BI i, BI j, BP p )
1759  {
1760  EnsureUnique();
1761  return pcl::SearchLast( m_data->begin, m_data->end, i, j, p );
1762  }
1763 
1766  template <class C>
1767  const_iterator SearchLastSubset( const C& x ) const noexcept
1768  {
1769  PCL_ASSERT_DIRECT_CONTAINER( C, T );
1770  return pcl::SearchLast( m_data->begin, m_data->end, x.Begin(), x.End() );
1771  }
1772 
1775  template <class C>
1777  {
1778  PCL_ASSERT_DIRECT_CONTAINER( C, T );
1779  EnsureUnique();
1780  return pcl::SearchLast( m_data->begin, m_data->end, x.Begin(), x.End() );
1781  }
1782 
1785  template <class C, class BP>
1786  const_iterator SearchLastSubset( const C& x, BP p ) const noexcept( noexcept( p ) )
1787  {
1788  PCL_ASSERT_DIRECT_CONTAINER( C, T );
1789  return pcl::SearchLast( m_data->begin, m_data->end, x.Begin(), x.End(), p );
1790  }
1791 
1794  template <class C, class BP>
1795  iterator SearchLastSubset( const C& x, BP p )
1796  {
1797  PCL_ASSERT_DIRECT_CONTAINER( C, T );
1798  EnsureUnique();
1799  return pcl::SearchLast( m_data->begin, m_data->end, x.Begin(), x.End(), p );
1800  }
1801 
1802 
1805  bool Contains( const T& v ) const noexcept
1806  {
1807  return Search( v ) != m_data->end;
1808  }
1809 
1812  template <class BP>
1813  bool Contains( const T& v, BP p ) const noexcept( noexcept( p ) )
1814  {
1815  return Search( v, p ) != m_data->end;
1816  }
1817 
1820  template <class FI>
1821  iterator ContainsSubset( FI i, FI j ) const noexcept
1822  {
1823  return SearchSubset( i, j ) != m_data->end;
1824  }
1825 
1828  template <class FI, class BP>
1829  iterator ContainsSubset( FI i, FI j, BP p ) const noexcept( noexcept( p ) )
1830  {
1831  return SearchSubset( i, j, p ) != m_data->end;
1832  }
1833 
1836  template <class C>
1837  iterator ContainsSubset( const C& c ) const noexcept
1838  {
1839  return SearchSubset( c ) != m_data->end;
1840  }
1841 
1844  template <class C, class BP>
1845  iterator ContainsSubset( const C& c, BP p ) const noexcept( noexcept( p ) )
1846  {
1847  return SearchSubset( c, p ) != m_data->end;
1848  }
1849 
1852  void Sort()
1853  {
1854  EnsureUnique();
1855  pcl::QuickSort( m_data->begin, m_data->end );
1856  }
1857 
1860  template <class BP>
1861  void Sort( BP p )
1862  {
1863  EnsureUnique();
1864  pcl::QuickSort( m_data->begin, m_data->end, p );
1865  }
1866 
1870  friend void Swap( Array& x1, Array& x2 ) noexcept
1871  {
1872  pcl::Swap( x1.m_data, x2.m_data );
1873  }
1874 
1891  template <class S, typename SP>
1892  S& ToSeparated( S& s, SP separator ) const
1893  {
1894  const_iterator i = m_data->begin;
1895  if ( i < m_data->end )
1896  {
1897  s.Append( S( *i ) );
1898  if ( ++i < m_data->end )
1899  do
1900  {
1901  s.Append( separator );
1902  s.Append( S( *i ) );
1903  }
1904  while ( ++i < m_data->end );
1905  }
1906  return s;
1907  }
1908 
1931  template <class S, typename SP, class AF>
1932  S& ToSeparated( S& s, SP separator, AF append ) const
1933  {
1934  const_iterator i = m_data->begin;
1935  if ( i < m_data->end )
1936  {
1937  append( s, S( *i ) );
1938  if ( ++i < m_data->end )
1939  {
1940  S p( separator );
1941  do
1942  {
1943  append( s, p );
1944  append( s, S( *i ) );
1945  }
1946  while ( ++i < m_data->end );
1947  }
1948  }
1949  return s;
1950  }
1951 
1960  template <class S>
1961  S& ToCommaSeparated( S& s ) const
1962  {
1963  return ToSeparated( s, ',' );
1964  }
1965 
1974  template <class S>
1975  S& ToSpaceSeparated( S& s ) const
1976  {
1977  return ToSeparated( s, ' ' );
1978  }
1979 
1988  template <class S>
1989  S& ToTabSeparated( S& s ) const
1990  {
1991  return ToSeparated( s, '\t' );
1992  }
1993 
2002  template <class S>
2003  S& ToNewLineSeparated( S& s ) const
2004  {
2005  return ToSeparated( s, '\n' );
2006  }
2007 
2016  uint64 Hash64( uint64 seed = 0 ) const
2017  {
2018  return pcl::Hash64( m_data->begin, m_data->Size(), seed );
2019  }
2020 
2029  uint32 Hash32( uint32 seed = 0 ) const noexcept
2030  {
2031  return pcl::Hash32( m_data->begin, m_data->Size(), seed );
2032  }
2033 
2038  uint64 Hash( uint64 seed = 0 ) const noexcept
2039  {
2040  return Hash64( seed );
2041  }
2042 
2043  // -------------------------------------------------------------------------
2044 
2045 private:
2046 
2052  struct Data : public ReferenceCounter
2053  {
2054  iterator begin = nullptr;
2055  iterator end = nullptr;
2056  iterator available = nullptr;
2057  allocator alloc;
2058 
2062  Data() = default;
2063 
2067  ~Data()
2068  {
2069  Deallocate();
2070  }
2071 
2075  size_type Size() const noexcept
2076  {
2077  return Length()*sizeof( T );
2078  }
2079 
2083  size_type Length() const noexcept
2084  {
2085  return end - begin;
2086  }
2087 
2091  size_type Capacity() const noexcept
2092  {
2093  return available - begin;
2094  }
2095 
2099  size_type Available() const noexcept
2100  {
2101  return available - end;
2102  }
2103 
2107  bool IsEmpty() const noexcept
2108  {
2109  return begin == end;
2110  }
2111 
2116  void Allocate( size_type n )
2117  {
2118  if ( n > 0 )
2119  {
2120  size_type m = alloc.PagedLength( n );
2121  begin = alloc.Allocate( m );
2122  end = begin + n;
2123  available = begin + m;
2124  }
2125  }
2126 
2130  void Deallocate()
2131  {
2132  PCL_CHECK( (begin == nullptr) ? end == nullptr : begin < end )
2133  if ( begin != nullptr )
2134  {
2135  Destroy( begin, end );
2136  alloc.Deallocate( begin );
2137  begin = end = available = nullptr;
2138  }
2139  }
2140 
2144  void Initialize( iterator __restrict__ i, iterator __restrict__ j )
2145  {
2146  for ( ; i < j; ++i )
2147  pcl::Construct( i, alloc );
2148  }
2149 
2154  void Initialize( iterator __restrict__ i, size_type n )
2155  {
2156  for ( ; n > 0; ++i, --n )
2157  pcl::Construct( i, alloc );
2158  }
2159 
2164  void Initialize( iterator __restrict__ i, iterator __restrict__ j, const T& v )
2165  {
2166  for ( ; i < j; ++i )
2167  pcl::Construct( i, v, alloc );
2168  }
2169 
2174  void Initialize( iterator __restrict__ i, size_type n, const T& v )
2175  {
2176  for ( ; n > 0; ++i, --n )
2177  pcl::Construct( i, v, alloc );
2178  }
2179 
2185  template <class FI>
2186  iterator Build( iterator __restrict__ i, FI p, FI q )
2187  {
2188  for ( ; p != q; ++i, ++p )
2189  pcl::Construct( i, *p, alloc );
2190  return i;
2191  }
2192 
2198  iterator UninitializedGrow( iterator __restrict__ i, size_type n )
2199  {
2200  if ( n > 0 )
2201  if ( Available() >= n )
2202  {
2203  if ( i < end )
2204  {
2205  iterator __restrict__ j1 = end;
2206  iterator __restrict__ j2 = end + n;
2207 
2208  for ( ;; )
2209  {
2210  pcl::Construct( --j2, *--j1, alloc );
2211 
2212  if ( j1 == i )
2213  {
2214  j2 = end;
2215  break;
2216  }
2217  else if ( j2 == end )
2218  {
2219  do
2220  *--j2 = *--j1;
2221  while ( j1 > i );
2222  break;
2223  }
2224  }
2225 
2226  Destroy( i, j2 );
2227  }
2228  end += n;
2229  }
2230  else
2231  {
2232  size_type m = alloc.PagedLength( Length()+n );
2233  iterator b = alloc.Allocate( m );
2234  iterator r = Build( b, begin, i );
2235  iterator e = Build( r+n, i, end );
2236 
2237  Deallocate();
2238  begin = b;
2239  end = e;
2240  available = b + m;
2241  i = r;
2242  }
2243 
2244  return i;
2245  }
2246 
2250  static void Destroy( iterator i, iterator j )
2251  {
2252  pcl::Destroy( i, j );
2253  }
2254  };
2255 
2260  Data* m_data = nullptr;
2261 
2266  void DetachFromData()
2267  {
2268  if ( !m_data->Detach() )
2269  delete m_data;
2270  }
2271 };
2272 
2273 // ----------------------------------------------------------------------------
2274 
2284 template <class T, class A> inline
2285 bool operator ==( const Array<T,A>& x1, const Array<T,A>& x2 ) noexcept
2286 {
2287  return x1.Length() == x2.Length() && pcl::Equal( x1.Begin(), x2.Begin(), x2.End() );
2288 }
2289 
2295 template <class T, class A> inline
2296 bool operator <( const Array<T,A>& x1, const Array<T,A>& x2 ) noexcept
2297 {
2298  return pcl::Compare( x1.Begin(), x1.End(), x2.Begin(), x2.End() ) < 0;
2299 }
2300 
2312 template <class T, class A, class V> inline
2313 Array<T,A>& operator <<( Array<T,A>& x, const V& v )
2314 {
2315  x.Append( T( v ) );
2316  return x;
2317 }
2318 
2326 template <class T, class A, class V> inline
2327 Array<T,A>& operator <<( Array<T,A>&& x, const V& v )
2328 {
2329  x.Append( T( v ) );
2330  return x;
2331 }
2332 
2338 template <class T, class A> inline
2339 Array<T,A>& operator <<( Array<T,A>& x1, const Array<T,A>& x2 )
2340 {
2341  x1.Append( x2 );
2342  return x1;
2343 }
2344 
2350 template <class T, class A> inline
2351 Array<T,A>& operator <<( Array<T,A>&& x1, const Array<T,A>& x2 )
2352 {
2353  x1.Append( x2 );
2354  return x1;
2355 }
2356 
2357 // ----------------------------------------------------------------------------
2358 
2359 } // pcl
2360 
2361 #endif // __PCL_Array_h
2362 
2363 // ----------------------------------------------------------------------------
2364 // EOF pcl/Array.h - Released 2024-12-23T11:32:56Z
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:1758
const_iterator MinItem() const noexcept
Definition: Array.h:1483
iterator SearchSubset(const C &x, BP p)
Definition: Array.h:1723
iterator ContainsSubset(const C &c, BP p) const noexcept(noexcept(p))
Definition: Array.h:1845
uint64 Hash64(uint64 seed=0) const
Definition: Array.h:2016
void Shrink(size_type n=1)
Definition: Array.h:863
iterator SearchLast(const T &v, BP p)
Definition: Array.h:1652
void Import(iterator i, iterator j)
Definition: Array.h:789
bool IsEmpty() const noexcept
Definition: Array.h:324
size_type LowerBound() const noexcept
Definition: Array.h:333
void Apply(F f) const noexcept(noexcept(f))
Definition: Array.h:1419
void Remove(iterator i, iterator j)
Definition: Array.h:1062
friend void Swap(Array &x1, Array &x2) noexcept
Definition: Array.h:1870
void ShiftRight(const T &v, size_type n=1)
Definition: Array.h:1582
void Sort()
Definition: Array.h:1852
Array(const Array &x)
Definition: Array.h:200
void Prepend(FI p, FI q)
Definition: Array.h:1009
void Squeeze()
Definition: Array.h:1351
~Array()
Definition: Array.h:220
iterator Begin()
Definition: Array.h:438
iterator Grow(iterator i, size_type n=1)
Definition: Array.h:834
const_iterator SearchLastSubset(BI i, BI j) const noexcept
Definition: Array.h:1733
iterator Expand(size_type n=1)
Definition: Array.h:854
void Prepend(const T &v, size_type n=1)
Definition: Array.h:997
iterator MaxItem(BP p)
Definition: Array.h:1539
iterator MinItem()
Definition: Array.h:1490
const allocator & Allocator() const noexcept
Definition: Array.h:350
iterator SearchSubset(FI i, FI j, BP p)
Definition: Array.h:1686
const_iterator MinItem(BP p) const noexcept(noexcept(p))
Definition: Array.h:1499
void Transfer(Array &x)
Definition: Array.h:683
void Rotate(distance_type n)
Definition: Array.h:1555
const_iterator ConstEnd() const noexcept
Definition: Array.h:480
iterator At(size_type i)
Definition: Array.h:367
void UniquifyIterators(iterator &i, iterator &j)
Definition: Array.h:590
iterator ContainsSubset(const C &c) const noexcept
Definition: Array.h:1837
Array(size_type n)
Definition: Array.h:153
iterator SearchSubset(FI i, FI j)
Definition: Array.h:1669
uint64 Hash(uint64 seed=0) const noexcept
Definition: Array.h:2038
size_type Length() const noexcept
Definition: Array.h:278
Array(size_type n, const T &v)
Definition: Array.h:163
const_iterator SearchLastSubset(const C &x) const noexcept
Definition: Array.h:1767
iterator Replace(iterator i, iterator j, FI p, FI q)
Definition: Array.h:1282
void Resize(size_type n)
Definition: Array.h:880
void Add(const T &v, size_type n=1)
Definition: Array.h:1025
void Apply(F f)
Definition: Array.h:1408
bool IsValid() const noexcept
Definition: Array.h:316
void UniquifyIterator(iterator &i)
Definition: Array.h:570
bool IsAliasOf(const Array &x) const noexcept
Definition: Array.h:242
iterator end()
Definition: Array.h:623
const_iterator End() const noexcept
Definition: Array.h:472
bool IsUnique() const noexcept
Definition: Array.h:232
void Assign(const T &v, size_type n=1)
Definition: Array.h:716
iterator FirstThat(F f)
Definition: Array.h:1441
void Append(const T &v, size_type n=1)
Definition: Array.h:967
void Append(const Array &x)
Definition: Array.h:958
void ShiftLeft(const T &v, size_type n=1)
Definition: Array.h:1568
void Remove(const T &v)
Definition: Array.h:1127
iterator SearchLastSubset(const C &x)
Definition: Array.h:1776
uint32 Hash32(uint32 seed=0) const noexcept
Definition: Array.h:2029
void Sort(BP p)
Definition: Array.h:1861
void Add(const Array &x)
Definition: Array.h:1017
const_iterator SearchSubset(const C &x) const noexcept
Definition: Array.h:1695
bool Contains(const T &v) const noexcept
Definition: Array.h:1805
size_type Count(const T &v) const noexcept
Definition: Array.h:1460
void Transfer(Array &&x)
Definition: Array.h:702
const_reverse_iterator ReverseEnd() const noexcept
Definition: Array.h:543
iterator Replace(iterator i, iterator j, const Array &x)
Definition: Array.h:1217
Array()
Definition: Array.h:144
void SetAllocator(const allocator &a)
Definition: Array.h:358
Array(FI i, FI j)
Definition: Array.h:175
iterator End()
Definition: Array.h:463
iterator SearchLast(const T &v)
Definition: Array.h:1635
void Remove(const T &v, BP p)
Definition: Array.h:1156
iterator ContainsSubset(FI i, FI j, BP p) const noexcept(noexcept(p))
Definition: Array.h:1829
const_reverse_iterator ConstReverseBegin() const noexcept
Definition: Array.h:516
void Assign(const Array &x)
Definition: Array.h:658
const_iterator Begin() const noexcept
Definition: Array.h:447
void Assign(FI i, FI j)
Definition: Array.h:751
Array(std::initializer_list< T1 > l)
Definition: Array.h:192
void Prepend(const Array &x)
Definition: Array.h:988
const_iterator SearchLastSubset(BI i, BI j, BP p) const noexcept(noexcept(p))
Definition: Array.h:1750
const_iterator MaxItem() const noexcept
Definition: Array.h:1515
const_iterator LastThat(F f) const noexcept(noexcept(f))
Definition: Array.h:1453
bool Contains(const T &v, BP p) const noexcept(noexcept(p))
Definition: Array.h:1813
void RemoveLast(size_type n=1)
Definition: Array.h:1103
typename container_type::const_item_type const_item_type
Definition: Array.h:113
size_type UpperBound() const noexcept
Definition: Array.h:342
const_iterator SearchSubset(FI i, FI j) const noexcept
Definition: Array.h:1661
iterator SearchSubset(const C &x)
Definition: Array.h:1704
iterator Replace(iterator i, iterator j, const T &v, size_type n=1)
Definition: Array.h:1239
const_iterator SearchSubset(const C &x, BP p) const noexcept(noexcept(p))
Definition: Array.h:1714
size_type Count(const T &v, BP p) const noexcept(noexcept(p))
Definition: Array.h:1468
const_iterator begin() const noexcept
Definition: Array.h:615
const_reverse_iterator ConstReverseEnd() const noexcept
Definition: Array.h:556
iterator Insert(iterator i, FI p, FI q)
Definition: Array.h:943
void Clear()
Definition: Array.h:1191
iterator Search(const T &v, BP p)
Definition: Array.h:1620
reverse_iterator ReverseEnd()
Definition: Array.h:529
const_iterator SearchSubset(FI i, FI j, BP p) const noexcept(noexcept(p))
Definition: Array.h:1678
iterator Insert(iterator i, const Array &x)
Definition: Array.h:900
void Reverse()
Definition: Array.h:1547
iterator Insert(iterator i, const T &v, size_type n=1)
Definition: Array.h:919
void EnsureUnique()
Definition: Array.h:254
const_iterator At(size_type i) const noexcept
Definition: Array.h:377
iterator ContainsSubset(FI i, FI j) const noexcept
Definition: Array.h:1821
A block_allocator
Definition: Array.h:117
void Append(FI p, FI q)
Definition: Array.h:979
const_iterator Search(const T &v) const noexcept
Definition: Array.h:1596
reverse_iterator ReverseBegin()
Definition: Array.h:491
size_type Capacity() const noexcept
Definition: Array.h:287
const_iterator end() const noexcept
Definition: Array.h:631
const_iterator FirstThat(F f) const noexcept(noexcept(f))
Definition: Array.h:1430
Array(Array &&x)
Definition: Array.h:210
void Truncate(iterator i)
Definition: Array.h:1118
iterator MaxItem()
Definition: Array.h:1522
iterator SearchLastSubset(const C &x, BP p)
Definition: Array.h:1795
const_iterator Search(const T &v, BP p) const noexcept(noexcept(p))
Definition: Array.h:1612
void Fill(const T &v)
Definition: Array.h:1380
iterator Release()
Definition: Array.h:816
void SecureFill(const T &v)
Definition: Array.h:1398
size_type Size() const noexcept
Definition: Array.h:270
const_iterator MaxItem(BP p) const noexcept(noexcept(p))
Definition: Array.h:1531
void Reserve(size_type n)
Definition: Array.h:1313
const_iterator ConstBegin() const noexcept
Definition: Array.h:455
size_type CountIf(UP p) const noexcept(noexcept(p))
Definition: Array.h:1476
T * iterator
Definition: Array.h:125
iterator MinItem(BP p)
Definition: Array.h:1507
const T * const_iterator
Definition: Array.h:129
const_iterator SearchLastSubset(const C &x, BP p) const noexcept(noexcept(p))
Definition: Array.h:1786
void Add(FI p, FI q)
Definition: Array.h:1034
const_iterator SearchLast(const T &v) const noexcept
Definition: Array.h:1628
iterator begin()
Definition: Array.h:607
void Remove(iterator i, size_type n=1)
Definition: Array.h:1048
const_iterator SearchLast(const T &v, BP p) const noexcept(noexcept(p))
Definition: Array.h:1644
const_reverse_iterator ReverseBegin() const noexcept
Definition: Array.h:504
iterator SearchLastSubset(BI i, BI j)
Definition: Array.h:1741
iterator Search(const T &v)
Definition: Array.h:1603
void RemoveFirst(size_type n=1)
Definition: Array.h:1089
size_type Available() const noexcept
Definition: Array.h:298
iterator MutableIterator(const_iterator i)
Definition: Array.h:393
typename container_type::item_type item_type
Definition: Array.h:109
Root base class of all PCL containers of objects.
Definition: Container.h:78
const T const_item_type
Definition: Container.h:89
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:2313
bool operator==(const Array< T, A > &x1, const Array< T, A > &x2) noexcept
Definition: Array.h:2285
bool operator<(const Array< T, A > &x1, const Array< T, A > &x2) noexcept
Definition: Array.h:2296
Complex< T1 > operator*(const Complex< T1 > &c1, const Complex< T2 > &c2) noexcept
Definition: Complex.h:562
uint64 Hash64(const void *data, size_type size, uint64 seed=0) noexcept
Definition: Math.h:4830
uint32 Hash32(const void *data, size_type size, uint32 seed=0) noexcept
Definition: Math.h:4984
void Rotate(T &x, T &y, T1 sa, T1 ca, T2 xc, T2 yc) noexcept
Definition: Math.h:2055
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