1 #ifndef SimTK_SimTKCOMMON_ARRAY_H_     2 #define SimTK_SimTKCOMMON_ARRAY_H_    43 #include <type_traits>    44 #include <initializer_list>    53 template <
class T, 
class X=
unsigned> 
class  Array_;
   121     static size_type 
max_size() {
return X::max_size();}
   129     static size_type        
max_size() {
return (
unsigned)INT_MAX;}
   149     static size_type            
max_size() {
return (
unsigned long)LONG_MAX;}
   217     static size_type            
max_size() {
return (
char)SCHAR_MAX;}
   237                                     {
return (
unsigned long long)LLONG_MAX;}
   258 template <
class Integral, 
class is64Bit> 
struct ArrayIndexPackTypeHelper 
   259 {   
typedef Integral packed_size_type;};
   262 template<> 
struct ArrayIndexPackTypeHelper<bool,FalseType> 
   263 {   
typedef unsigned short packed_size_type;};
   264 template<> 
struct ArrayIndexPackTypeHelper<char,FalseType> 
   265 {   
typedef unsigned short packed_size_type;};
   266 template<> 
struct ArrayIndexPackTypeHelper<unsigned char,FalseType> 
   267 {   
typedef unsigned short packed_size_type;};
   268 template<> 
struct ArrayIndexPackTypeHelper<signed char,FalseType> 
   269 {   
typedef short packed_size_type;};
   272 template<> 
struct ArrayIndexPackTypeHelper<bool,TrueType> 
   273 {   
typedef unsigned int packed_size_type;};
   274 template<> 
struct ArrayIndexPackTypeHelper<char,TrueType> 
   275 {   
typedef unsigned int packed_size_type;};
   276 template<> 
struct ArrayIndexPackTypeHelper<unsigned char,TrueType> 
   277 {   
typedef unsigned int packed_size_type;};
   278 template<> 
struct ArrayIndexPackTypeHelper<signed char,TrueType> 
   279 {   
typedef int packed_size_type;};
   280 template<> 
struct ArrayIndexPackTypeHelper<unsigned short,TrueType> 
   281 {   
typedef unsigned int packed_size_type;};
   282 template<> 
struct ArrayIndexPackTypeHelper<short,TrueType> 
   283 {   
typedef int packed_size_type;};
   285 template <
class Integral> 
struct ArrayIndexPackType
   286 {   
typedef typename ArrayIndexPackTypeHelper<Integral,Is64BitPlatformType>
   287                         ::packed_size_type  packed_size_type;};
   360 typedef typename ArrayIndexPackType<size_type>::packed_size_type 
   385 :   pData(0), nUsed(src.nUsed), nAllocated(0) {
   386     if (nUsed) pData = 
const_cast<T*
>(src.pData);
   414 :   pData(0),nUsed(0),nAllocated(0) { 
   415     if (last1==first) 
return; 
   418         "ArrayViewConst_<T>(first,last1)", 
   419         "One of the source pointers was null (0); either both must be"   420         " non-null or both must be null.");
   423         "ArrayViewConst_<T>(first,last1)",
   424         "The source data's size %llu is too big for this array which"   425         " is limited to %llu elements by its index type %s.",
   426         this->ull(last1-first), ullMaxSize(), indexName());
   428     pData = 
const_cast<T*
>(first); 
   429     nUsed = packed_size_type(last1-first); 
   462 :   pData(0),nUsed(0),nAllocated(0) { 
   463     if (src.empty()) 
return;
   466         "ArrayViewConst_<T>::ctor(std::vector<T>)",
   467         "The source std::vector's size %llu is too big for this array which"   468         " is limited to %llu elements by its index type %s.",
   469         this->ull(src.size()), ullMaxSize(), indexName());
   471     pData = 
const_cast<T*
>(&src.front()); 
   472     nUsed = packed_size_type(src.size()); 
   482 {   
return *
reinterpret_cast<const Array_<T,X>*
>(
this); }
   491         "ArrayViewConst_::deallocate(): called on an owner Array_");
   513 size_type 
size()
 const {
return size_type(nUsed);}
   519 bool empty()
 const {
return nUsed==0;}
   525 {   
return size_type(nAllocated?nAllocated:nUsed); }
   529 size_type 
allocated()
 const {
return size_type(nAllocated);}
   535 bool isOwner()
 const {
return nAllocated || pData==0;}
   562 const T& 
at(index_type i)
 const {
   578 {   
SimTK_ERRCHK(!empty(), 
"ArrayViewConst_<T>::front()", 
"Array was empty.");
   586 {   
SimTK_ERRCHK(!empty(), 
"ArrayViewConst_<T>::back()", 
"Array was empty.");
   587     return pData[nUsed-1]; }
   608     const size_type ix(index);
   610         "For this operator, we must have 0 <= index <= size(), but"   611         " index==%llu and size==%llu.", this->ull(ix), ullSize());
   613         "ArrayViewConst_<T>(index,length)", 
   614         "This operator requires 0 <= length <= size()-index, but"   615         " length==%llu and size()-index==%llu.",this->ull(length),this->ull(size()-ix));
   622 {   
return (*
this)(index,length); }
   646 const T* 
cend()
 const {
return pData + nUsed;}
   648 const T* 
begin()
 const {
return pData;}
   650 const T* 
end()
 const {
return pData + nUsed;}
   655 {   
return const_reverse_iterator(cend()); }
   659 const_reverse_iterator 
crend()
 const    660 {   
return const_reverse_iterator(cbegin()); }
   662 const_reverse_iterator 
rbegin()
 const {
return crbegin();} 
   664 const_reverse_iterator 
rend()
 const {
return crend();}
   672 const T* 
cdata()
 const {
return pData;}
   674 const T* 
data()
 const {
return pData;}
   687 packed_size_type psize()
 const {
return nUsed;}
   688 packed_size_type pallocated()
 const {
return nAllocated;}
   691 void setData(
const T* p)        {pData = 
const_cast<T*
>(p);}
   692 void setSize(size_type n)       {nUsed = packed_size_type(n);}
   693 void incrSize()                 {++nUsed;}
   694 void decrSize()                 {--nUsed;}
   695 void setAllocated(size_type n)  {nAllocated = packed_size_type(n);}
   700 bool isSameSize(S sz)
 const   701 {   
return ull(sz) == ullSize(); }
   706 bool isSizeOK(S srcSz)
 const   707 {   
return ull(srcSz) <= ullMaxSize(); }
   714 template<
class Iter> 
static   715 typename std::iterator_traits<Iter>::difference_type
   716 iterDistance(
const Iter& first, 
const Iter& last1) {
   717     return iterDistanceImpl(first,last1,
   718                 typename std::iterator_traits<Iter>::iterator_category());
   724 template<
class Iter> 
static   725 typename std::iterator_traits<Iter>::difference_type
   726 iterDistanceImpl(
const Iter& first, 
const Iter& last1, std::input_iterator_tag) {
   727     typename std::iterator_traits<Iter>::difference_type d = 0;
   728     for (Iter src=first; src != last1; ++src, ++d)
   735 template<
class Iter> 
static   736 typename std::iterator_traits<Iter>::difference_type
   737 iterDistanceImpl(
const Iter& first, 
const Iter& last1, 
   738                  std::random_access_iterator_tag) {
   739     return last1 - first;
   751 template<
class Iter> 
bool   752 overlapsWithData(
const Iter& first, 
const Iter& last1) {
   753     return overlapsWithDataImpl(first,last1,
   754                 typename std::iterator_traits<Iter>::iterator_category());
   759 template <
class T2> 
bool   760 overlapsWithData(
const T2* first, 
const T2* last1) {
   766     const T* obegin = 
std::max(cbegin(), (
const T*)first);
   767     const T* oend1  = 
std::min(cend(),   (
const T*)last1);
   769     return obegin < oend1;
   774 template<
class Iter> 
bool   775 overlapsWithDataImpl(
const Iter&, 
const Iter&, std::input_iterator_tag) 
   780 template<
class Iter> 
bool   781 overlapsWithDataImpl(
const Iter& first, 
const Iter& last1, 
   782                      std::random_access_iterator_tag) {
   793     return overlapsWithData(&*first, &*(last1-1)); 
   800 static unsigned long long ull(S sz)
   801 {   
return (
unsigned long long)sz; }
   804 unsigned long long ullSize()
     const {
return ull(size());}
   805 unsigned long long ullCapacity()
 const {
return ull(capacity());}
   806 unsigned long long ullMaxSize()
  const {
return ull(max_size());}
   820 packed_size_type    nUsed;      
   821 packed_size_type    nAllocated; 
   866 typedef typename ArrayIndexPackType<size_type>::packed_size_type 
   893 {   
return *
reinterpret_cast<const Array_<T,X>*
>(
this); }  
   925         avAssignIteratorDispatch(src.
cbegin(), src.
cend(),
   926                                  std::random_access_iterator_tag(),
   927                                  "ArrayView_<T>::operator=(ArrayView_<T>)");
   934 template <
class T2, 
class X2>
   936     if ((
const void*)&src != (
void*)
this)
   937         avAssignIteratorDispatch(src.
cbegin(), src.
cend(),
   938                                  std::random_access_iterator_tag(),
   939                                  "ArrayView_<T>::operator=(Array_<T2>)");
   948 template <
class T2, 
class X2>
   953 template <
class T2, 
class X2>
   959 template <
class T2, 
class A2>
   961     avAssignIteratorDispatch(src.begin(), src.end(),
   962                              std::random_access_iterator_tag(),
   963                              "ArrayView_<T>::operator=(std::vector<T2>)");
   969 {   fill(fillValue); 
return *
this; }
   977     for (T* d = begin(); d != end(); ++d)
   985 void assign(size_type n, 
const T& fillValue) {
   987         "Assignment to an ArrayView is permitted only if the source"   988         " is the same size. Here n==%llu element(s) but the"   989         " ArrayView has a fixed size of %llu.", 
   990         this->ull(n), this->ull(size()));
  1013 void assign(
const T2* first, 
const T2* last1) {
  1014     const char* methodName = 
"ArrayView_<T>::assign(T2* first, T2* last1)";
  1015     SimTK_ERRCHK((first&&last1)||(first==last1), methodName, 
  1016         "One of the source pointers was null (0); either both must be"  1017         " non-null or both must be null.");
  1019     avAssignIteratorDispatch(first, last1, std::random_access_iterator_tag(),
  1054 template <
class Iter>
  1055 void assign(
const Iter& first, 
const Iter& last1)
  1057                      "ArrayView_<T>::assign(Iter first, Iter last1)"); }
  1076 {   
return this->CBase::operator[](i); }
  1086 {   
return const_cast<T&
>(this->CBase::operator[](i)); }
  1092 const T& 
at(index_type i)
 const {
return this->CBase::at(i);}
  1098 T& 
at(index_type i) {
return const_cast<T&
>(this->CBase::at(i));}
  1103 {   
return this->CBase::getElt(i); }
  1107 {   
return const_cast<T&
>(this->CBase::getElt(i)); }
  1156     const size_type ix(index);
  1158         "For this operator, we must have 0 <= index <= size(), but"  1159         " index==%llu and size==%llu.", this->ull(ix), ullSize());
  1161         "ArrayView_<T>(index,length)", 
  1162         "This operator requires 0 <= length <= size()-index, but"  1163         " length==%llu and size()-index==%llu.",this->ull(length),this->ull(size()-ix));
  1165     return ArrayView_(data()+ix, data()+ix+length);
  1170 {   
return (*
this)(index,length); }
  1213 {   
return this->CBase::crbegin(); }
  1216 {   
return this->CBase::crbegin(); } 
  1219 reverse_iterator 
rbegin() {
return reverse_iterator(end());}
  1225 {   
return this->CBase::crend(); }
  1227 const_reverse_iterator 
rend()
 const   1228 {   
return this->CBase::crend(); }
  1232 reverse_iterator 
rend() {
return reverse_iterator(begin());}
  1264 size_type 
max_size()
  const {
return this->CBase::max_size();}
  1265 bool      empty()
     const {
return this->CBase::empty();}
  1266 size_type 
capacity()
  const {
return this->CBase::capacity();}
  1267 size_type 
allocated()
 const {
return this->CBase::allocated();}
  1268 bool      isOwner()
   const {
return this->CBase::isOwner();}
  1283 template <
class IntegralType>
  1284 void avAssignDispatch(IntegralType n, IntegralType v, TrueType isIntegralType,
  1286 {   assign(size_type(n), value_type(v)); }
  1291 template <
class InputIterator> 
  1292 void avAssignDispatch(
const InputIterator& first, 
const InputIterator& last1, 
  1293                       FalseType isIntegralType, 
const char* methodName) 
  1294 {   avAssignIteratorDispatch(first, last1, 
  1295         typename std::iterator_traits<InputIterator>::iterator_category(),
  1304 template <
class InputIterator>
  1305 void avAssignIteratorDispatch(
const InputIterator& first, 
  1306                               const InputIterator& last1, 
  1307                               std::input_iterator_tag, 
  1308                               const char* methodName) 
  1311     InputIterator src = first;
  1312     while (src != last1 && p != end())
  1316     const size_type nCopied = size_type(p - begin());
  1318         "The supplied input_iterator provided only %llu elements but this"  1319         " ArrayView has a fixed size of %llu elements.",
  1320         this->ull(nCopied), ullSize());
  1329 template <
class ForwardIterator>
  1330 void avAssignIteratorDispatch(
const ForwardIterator& first, 
  1331                               const ForwardIterator& last1,
  1332                               std::forward_iterator_tag, 
  1333                               const char* methodName) 
  1336     ForwardIterator src = first;
  1337     while (src != last1 && p != end())
  1341     const size_type nCopied = size_type(p - begin());
  1343         "The supplied forward_ or bidirectional_iterator source range provided"  1344         " only %llu elements but this ArrayView has a fixed size of"  1345         " %llu elements.", this->ull(nCopied), ullSize());
  1349         "The supplied forward_ or bidirectional_iterator source range"  1350         " contained too many elements; this ArrayView has a fixed size of"  1351         " %llu elements.", ullSize());
  1358 template <
class RandomAccessIterator>
  1359 void avAssignIteratorDispatch(
const RandomAccessIterator& first, 
  1360                               const RandomAccessIterator& last1,
  1361                               std::random_access_iterator_tag, 
  1362                               const char* methodName) 
  1365         "Assignment to an ArrayView is permitted only if the source"  1366         " is the same size. Here the source had %llu element(s) but the"  1367         " ArrayView has a fixed size of %llu.", 
  1368         this->ull(last1-first), this->ull(size()));
  1371         "Source range can't overlap with the destination data.");
  1374     RandomAccessIterator src = first;
  1388 {   
return this->CBase::psize(); }
  1390 {   
return this->CBase::pallocated(); }
  1394 unsigned long long ullSize()
     const   1395 {   
return this->CBase::ullSize(); }
  1396 unsigned long long ullCapacity()
 const   1397 {   
return this->CBase::ullCapacity(); }
  1398 unsigned long long ullMaxSize()
  const   1399 {   
return this->CBase::ullMaxSize(); }
  1402 const char* indexName()
 const   {
return this->CBase::indexName();}
  1546 typedef typename ArrayIndexPackType<size_type>::packed_size_type 
  1568     allocateNoConstruct(n);
  1569     defaultConstruct(data(), data()+n);
  1576 Array_(size_type n, 
const T& initVal) : Base() {
  1579     allocateNoConstruct(size());
  1580     fillConstruct(begin(), cend(), initVal);
  1597 template <
class InputIter>
  1598 Array_(
const InputIter& first, 
const InputIter& last1) : Base() {
  1608 Array_(
const T2* first, 
const T2* last1) : Base() {
  1609     static_assert(std::is_assignable<T&,T2>::value,
  1610         "Array_<T> construction from T2 requires that "  1611         "T2 implicitly converts to T");
  1612     SimTK_ERRCHK((first&&last1)||(first==last1), 
"Array_<T>(first,last1)", 
  1613         "Pointers must be non-null unless they are both null.");
  1614     SimTK_ERRCHK3(this->isSizeOK(last1-first), 
"Array_<T>(first,last1)",
  1615         "Source has %llu elements but this array is limited to %llu"  1616         " elements by its index type %s.",
  1617         this->ull(last1-first), ullMaxSize(), indexName());
  1619     setSize(size_type(last1-first));
  1620     allocateNoConstruct(size());
  1621     copyConstruct(begin(), cend(), first);
  1629 :   
Array_(ilist.begin(), ilist.end()) {} 
  1636 explicit Array_(
const std::vector<T2>& v) : Base() { 
  1637     if (v.empty()) 
return;
  1639     SimTK_ERRCHK3(this->isSizeOK(v.size()), 
"Array_<T>::ctor(std::vector<T2>)",
  1640         "The source std::vector's size %llu is too big for this array which"  1641         " is limited to %llu elements by its index type %s.",
  1642         this->ull(v.size()), ullMaxSize(), indexName());
  1647     new (
this) 
Array_(&v.front(), (&v.back())+1);
  1655     setSize(src.
size());
  1656     allocateNoConstruct(size());
  1657     copyConstruct(begin(), cend(), src.
data());
  1672 template <
class T2, 
class X2>
  1756         deallocateNoDestruct(); 
  1758     this->Base::disconnect(); 
  1818 void assign(size_type n, 
const T& fillValue) {
  1819     SimTK_ERRCHK3(this->isSizeOK(n), 
"Array_<T>::assign(n,value)",
  1820         "Requested size %llu is too big for this array which is limited"  1821         " to %llu elements by its index type %s.",
  1822         this->ull(n), ullMaxSize(), indexName());
  1824     SimTK_ERRCHK2(isOwner() || n==size(), 
"Array_<T>::assign(n,value)",
  1825         "Requested size %llu is not allowed because this is a non-owner"  1826         " array of fixed size %llu.", this->ull(n), this->ull(size()));
  1829         this->Base::fill(fillValue);
  1832         reallocateIfAdvisable(n); 
  1833         fillConstruct(data(), cdata()+n, fillValue);
  1852 void fill(
const T& fillValue) {this->Base::fill(fillValue);}
  1877 void assign(
const T2* first, 
const T2* last1) {
  1878     const char* methodName = 
"Array_<T>::assign(T2* first, T2* last1)";
  1879     SimTK_ERRCHK((first&&last1)||(first==last1), methodName, 
  1880         "Pointers must be non-null unless they are both null.");
  1881     SimTK_ERRCHK(!this->overlapsWithData(first,last1), methodName,
  1882         "Source range can't overlap the current array contents.");
  1884     assignIteratorDispatch(first,last1,std::random_access_iterator_tag(),
  1924 template <
class Iter>
  1925 void assign(
const Iter& first, 
const Iter& last1) {
  1927                    "Array_<T>::assign(Iter first, Iter last1)");
  1937         assignIteratorDispatch(src.
begin(), src.
end(), 
  1938                                std::random_access_iterator_tag(),
  1939                                "Array_<T>::operator=(Array_<T>)");
  1955 template <
class T2, 
class X2>
  1957     assignIteratorDispatch(src.
begin(), src.
end(), 
  1958                            std::random_access_iterator_tag(),
  1959                            "Array_<T>::operator=(Array_<T2,X2>)");
  1968 template <
class T2, 
class A>
  1970     assignIteratorDispatch(src.begin(), src.end(), 
  1971                            std::random_access_iterator_tag(),
  1972                            "Array_<T>::operator=(std::vector)");
  1984     T* 
const pTmp=data(); setData(other.
data()); other.setData(pTmp);
  1985     size_type nTmp=size(); setSize(other.
size()); other.setSize(nTmp);
  1986     nTmp=allocated(); setAllocated(other.
allocated()); other.setAllocated(nTmp);
  1995                   size_type dataCapacity) 
  1998     SimTK_ERRCHK2(dataSize <= dataCapacity, 
"Array_<T>::adoptData()", 
  1999         "Specified data size %llu was greater than the specified data"  2000         " capacity of %llu.", this->ull(dataSize), this->ull(dataCapacity));
  2001     SimTK_ERRCHK(newData || dataCapacity==0, 
"Array_<T>::adoptData()",
  2002         "A null data pointer is allowed only if the size and capacity are"  2003         " specified as zero.");
  2004     SimTK_ERRCHK(!this->overlapsWithData(newData, newData+dataSize), 
  2005         "Array_<T>::adoptData()",
  2006         "The new data can't overlap with the old data.");
  2011     setAllocated(dataCapacity);
  2017 {   
return adoptData(newData, dataSize, dataSize); }
  2035     SimTK_ERRCHK(newData || dataSize==0, 
"Array_<T>::shareData()",
  2036         "A null data pointer is allowed only if the size is zero.");
  2037     SimTK_ERRCHK(!this->overlapsWithData(newData, newData+dataSize), 
  2038         "Array_<T>::shareData()",
  2039         "The new data can't overlap with the old data.");
  2052         "Array_<T>::shareData(first,last1)",
  2053         "Requested size %llu is too big for this array which is limited"  2054         " to %llu elements by its index type %s.",
  2055         this->ull(last1-first), ullMaxSize(), indexName());
  2056     return shareData(first, size_type(last1-first));
  2077 size_type 
max_size()
 const {
return this->CBase::max_size();}
  2080 bool empty()
 const {
return this->CBase::empty();}
  2085 size_type 
capacity()
 const {
return this->CBase::capacity();}
  2092     if (n == size()) 
return;
  2095         "Requested size change to %llu is not allowed because this is a "  2096         "non-owner array of fixed size %llu.", 
  2097         this->ull(n), this->ull(size()));
  2100         erase(data()+n, cend());
  2105     defaultConstruct(data()+size(), cdata()+n); 
  2114     if (n == size()) 
return;
  2117         "Requested size change to %llu is not allowed because this is a"  2118         " non-owner array of fixed size %llu.", this->ull(n), this->ull(size()));
  2121         erase(data()+n, cend());
  2126     fillConstruct(data()+size(), cdata()+n, initVal);
  2137     if (capacity() >= n)
  2141         "Requested capacity change to %llu is not allowed because this is a "  2142         "non-owner array of fixed size %llu.", 
  2143         this->ull(n), this->ull(size()));
  2145     T* newData = allocN(n); 
  2146     moveConstructThenDestructSource(newData, newData+size(), data());
  2175     if (capacity() - size()/4 <= size()) 
  2177     T* newData = allocN(size());
  2178     moveConstructThenDestructSource(newData, newData+size(), data());
  2179     deallocateNoDestruct(); 
  2181     setAllocated(size());
  2188 {   
return this->CBase::allocated(); }
  2194 bool isOwner()
 const {
return this->CBase::isOwner();}
  2237 {   
return this->CBase::crbegin(); }
  2240 {   
return this->CBase::crbegin(); } 
  2243 reverse_iterator 
rbegin() {
return this->Base::rbegin();}
  2249 {   
return this->CBase::crend(); }
  2251 const_reverse_iterator 
rend()
 const   2252 {   
return this->CBase::crend(); }
  2256 reverse_iterator 
rend() {
return this->Base::rend();}
  2287 {   
return this->CBase::operator[](i); }
  2302 const T& 
at(index_type i)
 const {
return this->CBase::at(i);}
  2308 T& 
at(index_type i) {
return const_cast<T&
>(this->Base::at(i));}
  2313 {   
return this->CBase::getElt(i); }
  2349 {   
return CBase::operator()(index,length); }
  2353 {   
return CBase::getSubArray(index,length); }
  2358 {   
return Base::operator()(index,length); }
  2362 {   
return Base::updSubArray(index,length); }
  2400     if (pallocated() == psize())
  2401         growAtEnd(1,
"Array_<T>::push_back(const T& value)");
  2402     copyConstruct(end(), value);
  2411     if (pallocated() == psize())
  2412         growAtEnd(1,
"Array_<T>::push_back(T&& value)");
  2413     moveConstruct(end(), std::move(value));
  2425 template<
class... Args>
  2427     if (pallocated() == psize())
  2428         growAtEnd(1,
"Array_<T>::emplace_back(Args...)");
  2429     new(end()) T(std::forward<Args>(args)...); 
  2451     if (pallocated() == psize())
  2452         growAtEnd(1,
"Array_<T>::push_back()");
  2453     defaultConstruct(end());
  2478     if (pallocated() == psize())
  2479         growAtEnd(1,
"Array_<T>::raw_push_back()");
  2488     SimTK_ERRCHK(!empty(), 
"Array_<T>::pop_back()", 
"Array was empty.");
  2511     SimTK_ERRCHK(begin() <= first && first <= last1 && last1 <= end(),
  2512     "Array_<T>::erase(first,last1)", 
"Pointers out of range or out of order.");
  2514     const size_type nErased = size_type(last1-first);
  2515     SimTK_ERRCHK(isOwner() || nErased==0, 
"Array_<T>::erase(first,last1)",
  2516         "No elements can be erased from a non-owner array.");
  2519         destruct(first, last1); 
  2520         moveElementsDown(first+nErased, nErased); 
  2521         setSize(size()-nErased);
  2547         "Array_<T>::erase(p)", 
"Pointer must point to a valid element.");
  2549         "No elements can be erased from a non-owner array.");
  2552     moveElementsDown(p+1, 1); 
  2580         "Array_<T>::eraseFast(p)", 
"Pointer must point to a valid element.");
  2582         "No elements can be erased from a non-owner array.");
  2586         moveOneElement(p, &back());
  2599     SimTK_ERRCHK(isOwner() || empty(), 
"Array_<T>::clear()", 
  2600         "clear() is not allowed for a non-owner array.");
  2601     destruct(begin(), end());
  2632 T* 
insert(T* p, size_type n, 
const T& value) {
  2633     T* 
const gap = insertGapAt(p, n, 
"Array_<T>::insert(p,n,value)");
  2635     fillConstruct(gap, gap+n, value);
  2645     T* 
const gap = insertGapAt(p, 1, 
"Array_<T>::insert(p,value)");
  2647     copyConstruct(gap, value);
  2657 template <
class... Args>
  2659     T* 
const gap = insertGapAt(p, 1, 
"Array_<T>::emplace(p,Args...)");
  2661     new(gap) T(std::forward<Args>(args)...); 
  2696 T* 
insert(T* p, 
const T2* first, 
const T2* last1) {
  2697     const char* methodName = 
"Array_<T>::insert(T* p, T2* first, T2* last1)";
  2698     SimTK_ERRCHK((first&&last1) || (first==last1), methodName, 
  2699         "One of first or last1 was null; either both or neither must be null.");
  2700     SimTK_ERRCHK(!this->overlapsWithData(first,last1), methodName,
  2701         "Source range can't overlap with the current array contents.");
  2703     return insertIteratorDispatch(p, first, last1,
  2704                                   std::random_access_iterator_tag(),
  2710 template <
class Iter>
  2711 T* 
insert(T* p, 
const Iter& first, 
const Iter& last1) {
  2712     return insertDispatch(p, first, last1,
  2714                           "Array_<T>::insert(T* p, Iter first, Iter last1)");
  2739 T* growWithGap(T* gapPos, size_type gapSz, 
const char* methodName) {
  2743     SimTK_ERRCHK(begin() <= gapPos && gapPos <= end(), methodName, 
  2744         "Given insertion point is not valid for this array.");
  2747     setAllocated(calcNewCapacityForGrowthBy(gapSz, methodName));
  2748     T* newData   = allocN(allocated());
  2751     const size_type nBefore = (size_type)(gapPos-begin());
  2754     T* newGap    = newData + nBefore;
  2755     T* newGapEnd = newGap  + gapSz; 
  2758     moveConstructThenDestructSource(newData,   newGap,        data());
  2760     moveConstructThenDestructSource(newGapEnd, newData+size(), gapPos);
  2763     freeN(data()); setData(newData);
  2768 void growAtEnd(size_type n, 
const char* methodName) {
  2771     setAllocated(calcNewCapacityForGrowthBy(n, methodName));
  2772     T* newData   = allocN(allocated());
  2774     moveConstructThenDestructSource(newData, newData+size(), data());
  2776     freeN(data()); setData(newData);
  2787 size_type calcNewCapacityForGrowthBy(size_type n, 
const char* methodName)
 const {
  2789         "Can't grow this Array by %llu element(s) because it would"  2790         " then exceed the max_size of %llu set by its index type %s.",
  2791         (
unsigned long long)n, ullMaxSize(), indexName());
  2794     const size_type mustHave = capacity() + n;
  2798     const size_type wantToHave = capacity() <= max_size()/2 
  2811 T* insertGapAt(T* p, size_type n, 
const char* methodName) {
  2814         "Given insertion point is not valid for this Array.");
  2819         "No elements can be inserted into a non-owner array.");
  2823     const size_type before = (size_type)(p-begin()), after = (size_type)(end()-p);
  2828     if (capacity() >= size()+n) {
  2829         moveElementsUp(p, n); 
  2831         setAllocated(calcNewCapacityForGrowthBy(n, methodName));
  2832         T* newdata = allocN(allocated());
  2834         moveConstructThenDestructSource(newdata, newdata+before, data());
  2837         moveConstructThenDestructSource(newdata+before+n,
  2838                                         newdata+before+n+after,
  2840         p = newdata + before; 
  2853 template <
class IntegralType> 
void  2854 ctorDispatch(IntegralType n, IntegralType v, TrueType isIntegralType) {
  2855     new(
this) 
Array_(size_type(n), value_type(v));
  2866 template <
class InputIterator> 
void  2867 ctorDispatch(
const InputIterator& first, 
const InputIterator& last1, 
  2868              FalseType isIntegralType) 
  2869 {   ctorIteratorDispatch(first, last1, 
  2870         typename std::iterator_traits<InputIterator>::iterator_category()); }
  2878 template <
class InputIterator> 
void  2879 ctorIteratorDispatch(
const InputIterator& first, 
const InputIterator& last1, 
  2880                      std::input_iterator_tag) 
  2882     InputIterator src = first;
  2883     while (src != last1) {
  2889         if (size() == max_size()) {
  2892                 "Array_::ctor(InputIterator first, InputIterator last1)",
  2893                 "There were still source elements available when the array"  2894                 " reached its maximum size of %llu as determined by its index"  2895                 " type %s.", ullMaxSize(), indexName());
  2906 template <
class ForwardIterator> 
void  2907 ctorIteratorDispatch(
const ForwardIterator& first, 
const ForwardIterator& last1, 
  2908                      std::forward_iterator_tag) 
  2910     typedef typename std::iterator_traits<ForwardIterator>::difference_type
  2915     const difference_type nInput = this->iterDistance(first,last1);
  2918         "Array_(ForwardIterator first, ForwardIterator last1)", 
  2919         "Iterators were out of order.");
  2922         "Array_(ForwardIterator first, ForwardIterator last1)",
  2923         "Source has %llu elements but this array is limited to %llu"  2924         " elements by its index type %s.",
  2925         this->ull(nInput), ullMaxSize(), indexName());
  2927     const size_type n = size_type(nInput);
  2929     allocateNoConstruct(n);
  2930     copyConstruct(data(), data()+n, first);
  2938 template <
class IntegralType> 
  2939 T* insertDispatch(T* p, IntegralType n, IntegralType v, 
  2940                   TrueType isIntegralType, 
const char*) 
  2941 {   
return insert(p, size_type(n), value_type(v)); }
  2946 template <
class InputIterator> 
  2947 T* insertDispatch(T* p, 
const InputIterator& first, 
const InputIterator& last1, 
  2948                   FalseType isIntegralType, 
const char* methodName) 
  2949 {   
return insertIteratorDispatch(p, first, last1, 
  2950         typename std::iterator_traits<InputIterator>::iterator_category(),
  2956 template <
class InputIterator> 
  2957 T* insertIteratorDispatch(T* p, InputIterator first, InputIterator last1, 
  2958                           std::input_iterator_tag, 
const char* methodName) 
  2960     size_type nInserted = 0;
  2961     while (first != last1) {
  2964             "There were still source elements available when the array"  2965             " reached its maximum size of %llu as determined by its index"  2966             " type %s.", ullMaxSize(), indexName());
  2967         p = insert(p, *first++);  
  2980 template <
class ForwardIterator>
  2981 T* insertIteratorDispatch(T* p, 
const ForwardIterator& first, 
  2982                                 const ForwardIterator& last1,
  2983                                 std::forward_iterator_tag,
  2984                                 const char* methodName) 
  2986     typedef typename std::iterator_traits<ForwardIterator>::difference_type
  2991     const difference_type nInput = this->iterDistance(first,last1);
  2993     SimTK_ERRCHK(nInput >= 0, methodName, 
"Iterators were out of order.");
  2996         "Source has %llu elements which would make this array exceed the %llu"  2997         " elements allowed by its index type %s.",
  2998         this->ull(nInput), ullMaxSize(), indexName());
  3000     const size_type n = size_type(nInput);
  3001     p = insertGapAt(p, n, methodName);
  3002     copyConstruct(p, p+n, first);
  3012 template <
class IntegralType>
  3013 void assignDispatch(IntegralType n, IntegralType v, TrueType isIntegralType,
  3014                     const char* methodName) 
  3015 {   assign(size_type(n), value_type(v)); }
  3020 template <
class InputIterator> 
  3021 void assignDispatch(
const InputIterator& first, 
const InputIterator& last1, 
  3022                     FalseType isIntegralType, 
const char* methodName) 
  3023 {   assignIteratorDispatch(first, last1, 
  3024         typename std::iterator_traits<InputIterator>::iterator_category(),
  3030 template <
class InputIterator>
  3031 void assignIteratorDispatch(
const InputIterator& first, 
  3032                             const InputIterator& last1, 
  3033                             std::input_iterator_tag, 
  3034                             const char* methodName) 
  3039         "Assignment to a non-owner array can only be done from a source"  3040         " designated with forward iterators or pointers because we"  3041         " must be able to verify that the source and destination sizes"  3045     InputIterator src = first;
  3046     while (src != last1) {
  3049             "There were still source elements available when the array"  3050             " reached its maximum size of %llu as determined by its index"  3051             " type %s.", ullMaxSize(), indexName());
  3062 template <
class ForwardIterator>
  3063 void assignIteratorDispatch(
const ForwardIterator& first, 
  3064                             const ForwardIterator& last1,
  3065                             std::forward_iterator_tag, 
  3066                             const char* methodName) 
  3068     typedef typename std::iterator_traits<ForwardIterator>::difference_type
  3073     const IterDiffType nInput = this->iterDistance(first,last1);
  3075     SimTK_ERRCHK(nInput >= 0, methodName, 
"Iterators were out of order.");
  3078         "Source has %llu elements but this Array is limited to %llu"  3079         " elements by its index type %s.",
  3080         this->ull(nInput), ullMaxSize(), indexName());
  3082     const size_type n = size_type(nInput);
  3088         reallocateIfAdvisable(n); 
  3089         copyConstruct(data(), cdata()+n, first);
  3097             "Source has %llu elements which does not match the size %llu "  3098             "of the non-owner array it is being assigned into.",
  3099             this->ull(n), ullSize());
  3102         ForwardIterator src = first;
  3103         while (src != last1)
  3119 void reallocateIfAdvisable(size_type n) {
  3120     if (allocated() < n || allocated()/2 > 
std::max(minAlloc(), n)) 
  3121         reallocateNoDestructOrConstruct(n);
  3125 void allocateNoConstruct(size_type n) 
  3126 {   setData(allocN(n)); setAllocated(n); } 
  3127 void deallocateNoDestruct() 
  3128 {   freeN(data()); setData(0); setAllocated(0); } 
  3129 void reallocateNoDestructOrConstruct(size_type n)
  3130 {   deallocateNoDestruct(); allocateNoConstruct(n); }
  3133 size_type minAlloc()
 const   3134 {   
return std::min(max_size(), size_type(4)); }
  3139 static T* allocN(size_type n) {
  3141     unsigned char* newdata = 
new unsigned char[n * 
sizeof(T)];
  3143         unsigned char* b=newdata; 
  3144         const unsigned char* e=newdata+(n*
sizeof(T));
  3145         while (b != e) *b++ = 0xff;
  3147     return reinterpret_cast<T*
>(newdata);
  3152 static void freeN(T* p) {
  3153     delete[] 
reinterpret_cast<char*
>(p);
  3157 static void defaultConstruct(T* p) {
new(p) T();}
  3159 static void defaultConstruct(T* b, 
const T* e) 
  3160 {   
while (b!=e) 
new(b++) T(); }
  3163 static void fillConstruct(T* b, 
const T* e, 
const T& v)
  3164 {   
while(b!=e) 
new(b++) T(v); }
  3167 static void copyConstruct(T* p, 
const T& v) {
new(p) T(v);}
  3169 static void moveConstruct(T* p, T&& v) {
new(p) T(std::move(v));}
  3172 static void copyConstruct(T* b, 
const T* e, T* src)
  3173 {   
while(b!=e) 
new(b++) T(*src++); }
  3175 static void moveConstruct(T* b, 
const T* e, T* src)
  3176 {   
while(b!=e) 
new(b++) T(std::move(*src++)); }
  3180 template <
class InputIterator>
  3181 static void copyConstruct(T* b, 
const T* e, InputIterator src)
  3182 {   
while(b!=e) 
new(b++) T(*src++); }
  3188 static void copyConstructThenDestructSource(T* b, 
const T* e, T* src)
  3189 {   
while(b!=e) {
new(b++) T(*src); src++->~T();} }
  3195 static void moveConstructThenDestructSource(T* b, 
const T* e, T* src)
  3196 {   
while(b!=e) {
new(b++) T(std::move(*src)); src++->~T();} }
  3202 void moveOneElement(T* to, T* from) {
  3203     assert(data() <= to   && to   < data()+allocated());
  3204     assert(data() <= from && from < data()+allocated());
  3205     moveConstruct(to, std::move(*from)); 
  3212 void moveElementsDown(T* p, size_type n) {
  3214     for (; p != end(); ++p)
  3215         moveOneElement(p-n,p);
  3221 void moveElementsUp(T* p, size_type n) {
  3226         moveOneElement(src+n, src);;
  3231 static void destruct(T* p) {p->~T();}
  3233 static void destruct(T* b, 
const T* e)
  3234 {   
while(b!=e) b++->~T(); }
  3239 bool isGrowthOK(S n)
 const  3240 {   
return this->isSizeOK(ullCapacity() + this->ull(n)); }
  3252 void setData(
const T* p)       {this->CBase::setData(p);}
  3253 void setSize(size_type n)      {this->CBase::setSize(n);}
  3254 void incrSize()                {this->CBase::incrSize();}
  3255 void decrSize()                {this->CBase::decrSize();}
  3256 void setAllocated(size_type n) {this->CBase::setAllocated(n);}
  3259 unsigned long long ullSize()
     const   3260 {   
return this->CBase::ullSize(); }
  3261 unsigned long long ullCapacity()
 const   3262 {   
return this->CBase::ullCapacity(); }
  3263 unsigned long long ullMaxSize()
  const   3264 {   
return this->CBase::ullMaxSize(); }
  3267 const char* indexName()
 const   {
return this->CBase::indexName();}
  3279 template <
class T, 
class X> 
static inline   3285     if (!in.good()) {in.setstate(std::ios::failbit); 
return in;}
  3295         numRequired = isFixedSize ? out.
size() : 0;
  3303     std::ws(in); 
if (in.fail()) 
return in;
  3305         if (isFixedSize && numRequired != 0)
  3306             in.setstate(std::ios_base::failbit); 
  3314     typename       std::iostream::int_type ch;
  3316     #ifndef NDEBUG  // avoid unused variable warnings in Release  3317     const typename std::iostream::int_type EOFch = 
  3318         std::iostream::traits_type::eof();
  3322     bool lookForCloser = 
true;
  3323     ch = in.peek(); 
if (in.fail()) 
return in;
  3324     assert(ch != EOFch); 
  3326     char openBracket{
static_cast<char>(ch)}, closeBracket{};
  3327     if      (openBracket==
'(') {in.get(); closeBracket = 
')';}
  3328     else if (openBracket==
'[') {in.get(); closeBracket = 
']';}
  3329     else if (openBracket==
'{') {in.get(); closeBracket = 
'}';}
  3330     else lookForCloser = 
false;
  3336     if (in.good()) std::ws(in);
  3342             assert(lookForCloser); 
  3343             in.setstate(std::ios::failbit);
  3353     bool commaOK = 
true, commaRequired = 
false;
  3354     bool terminatorSeen = 
false;
  3371         if (lookForCloser) {
  3373             std::ws(in); 
if (!in.good()) 
break; 
  3374             ch = in.peek(); assert(ch != EOFch);
  3375             if (!in.good()) 
break;
  3377             if (c == closeBracket) {   
  3379                 terminatorSeen = 
true; 
  3389         if (isFixedSize && (nextIndex == numRequired))
  3393         if (commaOK && nextIndex != 0) {
  3395             std::ws(in); 
if (!in.good()) 
break; 
  3396             ch = in.peek(); assert(ch != EOFch);
  3397             if (!in.good()) 
break;
  3401                 commaRequired = 
true; 
  3404                 {   in.setstate(std::ios::failbit); 
break; }
  3405                 else commaOK = 
false; 
  3407             if (!in.good()) 
break; 
  3418         in >> out[nextIndex]; 
if (in.fail()) 
break;
  3421         if (!in.good()) 
break; 
  3435         if (lookForCloser && !terminatorSeen)
  3436             in.setstate(std::ios::failbit); 
  3438         if (isFixedSize && nextIndex != numRequired)
  3439             in.setstate(std::ios::failbit); 
  3471 template <
class T, 
class X> 
inline void  3473     for (X i(0); i < v.
size(); ++i) {
  3474         if (i != 0) o << 
" ";
  3483 template <
class T, 
class X> 
inline void  3486     for (X i(0); i < v.
size(); ++i) {
  3487         if (i != 0) o << 
',';
  3499 template <
class T, 
class X> 
inline   3507         for (
const T* p = a.
begin()+1; p != a.
end(); ++p)
  3517 template <
class T, 
class X> 
inline bool   3531 template <
class T, 
class X> 
inline bool   3533     for (X i(0); i < v.
size(); ++i)
  3544 template <
class T, 
class X> 
inline bool   3546     return !readArrayFromStream(in,v).fail();
  3554 template <
class T, 
class X> 
inline bool   3556     return !fillArrayViewFromStream(in,v).fail();
  3588 template <
class T, 
class X> 
static inline   3590 {   
return readArrayFromStreamHelper<T,X>(in, 
false , out); }
  3618 template <
class T, 
class X> 
static inline   3620 {   
return readArrayFromStreamHelper<T,X>(in, 
true , out); }
  3626 template <
class T, 
class X> 
static inline   3628 {   
return readArrayFromStreamHelper<T,X>(in, 
true , out); }
  3642 template <
class T, 
class X> 
inline  3644 {   
return readArrayFromStream<T,X>(in, out); }
  3653 template <
class T, 
class X> 
inline  3655 {   
return fillArrayViewFromStream<T,X>(in, out); }
  3669 template <
class T1, 
class X1, 
class T2, 
class X2> 
inline bool   3672     const ptrdiff_t sz1 = a1.
end()-a1.
begin();
  3673     const ptrdiff_t sz2 = a2.
end()-a2.
begin();
  3674     if (sz1 != sz2) 
return false;
  3675     const T1* p1 = a1.
begin();
  3676     const T2* p2 = a2.
begin();
  3677     while (p1 != a1.
end())
  3678         if (!(*p1++ == *p2++)) 
return false;
  3683 template <
class T1, 
class X1, 
class T2, 
class X2> 
inline bool   3685 {   
return !(a1 == a2); }
  3691 template <
class T1, 
class X1, 
class T2, 
class X2> 
inline bool   3693     const T1* p1 = a1.
begin();
  3694     const T2* p2 = a2.begin();
  3695     while (p1 != a1.end() && p2 != a2.end()) {
  3697             return *p1 < *p2; // otherwise p1 > p2
  3702     return p1 == a1.end() && p2 != a2.end();
  3706 template <
class T1, 
class X1, 
class T2, 
class X2> 
inline bool   3708 {   
return !(a1 < a2); }
  3712 template <
class T1, 
class X1, 
class T2, 
class X2> 
inline bool   3717 template <
class T1, 
class X1, 
class T2, 
class X2> 
inline bool   3719 {   
return !(a1 > a2); }
  3724 template <
class T1, 
class X1, 
class T2, 
class A2> 
inline bool   3731 template <
class T1, 
class A1, 
class T2, 
class X2> 
inline bool   3733 {   
return a2 == v1; }
  3737 template <
class T1, 
class X1, 
class T2, 
class A2> 
inline bool   3739 {   
return !(a1 == v2); }
  3742 template <
class T1, 
class A1, 
class T2, 
class X2> 
inline bool   3744 {   
return !(a2 == v1); }
  3751 template <
class T1, 
class X1, 
class T2, 
class A2> 
inline bool   3752 operator<(const ArrayViewConst_<T1,X1>& a1, 
const std::vector<T2,A2>& v2)
  3753 {   
return a1 < ArrayViewConst_<T2,size_t>(v2); }
  3760 template <
class T1, 
class A1, 
class T2, 
class X2> 
inline bool   3766 template <
class T1, 
class X1, 
class T2, 
class A2> 
inline bool   3768 {   
return !(a1 < v2); }
  3771 template <
class T1, 
class A1, 
class T2, 
class X2> 
inline bool   3773 {   
return !(v1 < a2); }
  3778 template <
class T1, 
class X1, 
class T2, 
class A2> 
inline bool   3784 template <
class T1, 
class A1, 
class T2, 
class X2> 
inline bool   3790 template <
class T1, 
class X1, 
class T2, 
class A2> 
inline bool   3791 operator<=(const ArrayViewConst_<T1,X1>& a1, 
const std::vector<T2,A2>& v2)
  3792 {   
return !(a1 > v2); }
  3795 template <
class T1, 
class A1, 
class T2, 
class X2> 
inline bool   3797 {   
return !(v1 > a2); }
  3807 template <
class T, 
class X> 
inline void  3814 #endif // SimTK_SimTKCOMMON_ARRAY_H_ const T & front() const
Return a const reference to the first element in this array, which must not be empty. 
Definition: Array.h:1114
 
size_type size() const
Return the current number of elements stored in this array. 
Definition: Array.h:513
 
void writeUnformatted(std::ostream &o, const Array_< T, X > &v)
Specialize writeUnformatted() for Array_<E,X> to delegate to element type E, with spaces separating t...
Definition: Array.h:3472
 
T & back()
Return a writable reference to the last element in this array, which must not be empty. 
Definition: Array.h:1135
 
This Array_ helper class is the base class for Array_, extending ArrayViewConst_ to add the ability t...
Definition: Array.h:52
 
bool readUnformatted(std::istream &in, ArrayView_< T, X > &v)
Specialization of readUnformatted() for fixed-length ArrayView_<T,X>; reads whitespace-separated toke...
Definition: Array.h:3532
 
Array_ & operator=(const Array_< T2, X2 > &src)
This is assignment from a source array whose element type T2 and/or index type X2 are different from ...
Definition: Array.h:1956
 
ArrayView_ & operator=(const ArrayViewConst_< T2, X2 > &src)
Assignment from any other array object is allowed as long as the number of elements matches and the t...
Definition: Array.h:935
 
ArrayIndexTraits< X >::difference_type difference_type
A signed integral type that can represent the difference between any two legitimate index values for ...
Definition: Array.h:358
 
size_type max_size() const
Return the maximum allowable size for this array. 
Definition: Array.h:2077
 
#define SimTK_ERRCHK2_ALWAYS(cond, whereChecked, fmt, a1, a2)
Definition: ExceptionMacros.h:289
 
void fill(const T &fillValue)
Assign all current elements of the array to the same fillValue. 
Definition: Array.h:1852
 
bool empty() const
Return true if there are no elements currently stored in this array. 
Definition: Array.h:2080
 
const_reverse_iterator crend() const
Return the past-the-end reverse iterator that tests equal to a reverse iterator that has been increme...
Definition: Array.h:2248
 
bool operator>(const ArrayViewConst_< T1, X1 > &a1, const std::vector< T2, A2 > &v2)
The greater than operator is implemented by using less than with the arguments reversed, meaning the elements must have working comparison operators of the form T2==T1 and T2<T1. 
Definition: Array.h:3779
 
T value_type
The type of object stored in this container. 
Definition: Array.h:335
 
void push_back(T &&value)
This is the move form of push_back(), taking an rvalue reference rather than an lvalue reference...
Definition: Array.h:2410
 
#define SimTK_SIZECHECK(sz, maxsz, where)
Definition: ExceptionMacros.h:146
 
ArrayView_()
Default constructor allocates no heap space and is very fast. 
Definition: Array.h:879
 
const T & at(index_type i) const
Same as operator[] but always range-checked, even in a Release build. 
Definition: Array.h:562
 
bool operator==(const ArrayViewConst_< T1, X1 > &a1, const std::vector< T2, A2 > &v2)
An Array_<T1> and an std::vector<T2> are equal if and only if they are the same size() and each eleme...
Definition: Array.h:3725
 
size_type size() const
Return the current number of elements stored in this array. 
Definition: Array.h:2075
 
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition: Array.h:863
 
~ArrayViewConst_()
The destructor just disconnects the array view handle from its data; see disconnect() for more inform...
Definition: Array.h:498
 
const T & getElt(index_type i) const
Same as the const form of operator[]; exists to provide a non-operator method for element access in c...
Definition: Array.h:2312
 
Array_(const Array_< T2, X2 > &src)
Construct this Array_<T,X> as a copy of another Array_<T2,X2> where T2!=T or X2!=X. 
Definition: Array.h:1673
 
T * iterator
A writable iterator for this container (same as pointer here). 
Definition: Array.h:347
 
const_reverse_iterator crend() const
Return the past-the-end reverse iterator that tests equal to a reverse iterator that has been increme...
Definition: Array.h:1224
 
const T * data() const
The const version of the data() method is identical to cdata(). 
Definition: Array.h:2267
 
ArrayViewConst_ operator()(index_type index, size_type length) const
Select a contiguous subarray of the elements of this array and create another ArrayViewConst_ that re...
Definition: Array.h:607
 
Array_(Array_ &&src)
Move constructor swaps in the source and leaves the source default constructed. 
Definition: Array.h:1662
 
This is a special type used for causing invocation of a particular constructor or method overload tha...
Definition: SimTKcommon/include/SimTKcommon/internal/common.h:670
 
const T & back() const
Return a const reference to the last element in this array, which must not be empty. 
Definition: Array.h:1128
 
#define SimTK_ERRCHK1_ALWAYS(cond, whereChecked, fmt, a1)
Definition: ExceptionMacros.h:285
 
void assign(size_type n, const T &fillValue)
Set this array to be n copies of the supplied fillValue. 
Definition: Array.h:1818
 
size_type capacity() const
Return the number of elements this array can currently hold without requiring reallocation. 
Definition: Array.h:524
 
const_reverse_iterator rbegin() const
The const version of rbegin() is the same as crbegin(). 
Definition: Array.h:662
 
std::reverse_iterator< iterator > reverse_iterator
Definition: Array.h:1542
 
const T & operator[](index_type i) const
Select an element by its index, returning a const reference. 
Definition: Array.h:2286
 
T & reference
Definition: Array.h:1538
 
void assign(const T2 *first, const T2 *last1)
Assign to this array to to make it a copy of the elements in range [first,last1) given by ordinary po...
Definition: Array.h:1877
 
bool readUnformatted(std::istream &in, T &v)
The default implementation of readUnformatted<T> reads in the next whitespace-separated token and the...
Definition: Serialize.h:176
 
This is the top-level SimTK namespace into which all SimTK names are placed to avoid collision with o...
Definition: Assembler.h:37
 
bool readUnformatted(std::istream &in, Array_< T, X > &v)
Specialization of readUnformatted() for variable-length Array_<T,X>; continues reading whitespace-sep...
Definition: Array.h:3518
 
ArrayViewConst_(const std::vector< T, A > &src)
Construct a ArrayViewConst_<T> by referencing (sharing) the data in a const std::vector<T>, without copying the data; this is also an implicit conversion. 
Definition: Array.h:461
 
void resize(size_type n)
Change the size of this Array, preserving all the elements that will still fit, and default construct...
Definition: Array.h:2091
 
T * iterator
Definition: Array.h:860
 
Array_(size_type n)
Construct an array containing n default-constructed elements. 
Definition: Array.h:1566
 
const T & const_reference
A const value_type reference. 
Definition: Array.h:345
 
T * pointer
A writable pointer to a value_type. 
Definition: Array.h:339
 
const T * cbegin() const
Return a const pointer to the first element of this array if any, otherwise cend(), which may be null (0) in that case but does not have to be. 
Definition: Array.h:2212
 
Array_(const InputIter &first, const InputIter &last1)
Construct an Array_<T> from a range [first,last1) of values identified by a pair of iterators...
Definition: Array.h:1598
 
bool operator!=(const std::vector< T1, A1 > &v1, const ArrayViewConst_< T2, X2 > &a2)
The not equal operator is implemented using the equal operator. 
Definition: Array.h:3743
 
T * pointer
Definition: Array.h:1536
 
bool isOwner() const
Does this array own the data to which it refers? If not, it can't be resized, and the destructor will...
Definition: Array.h:535
 
reverse_iterator rbegin()
Return a writable reverse iterator pointing to the last element in the array or rend() if the array i...
Definition: Array.h:2243
 
const T * data() const
The const version of the data() method is identical to cdata(). 
Definition: Array.h:674
 
T value_type
Definition: Array.h:854
 
const T * begin() const
The const version of begin() is the same as cbegin(). 
Definition: Array.h:1190
 
const T * end() const
The const version of end() is the same as cend(). 
Definition: Array.h:1203
 
ELEM min(const VectorBase< ELEM > &v)
Definition: VectorMath.h:178
 
T & at(index_type i)
Same as operator[] but always range-checked, even in a Release build. 
Definition: Array.h:2308
 
ArrayViewConst_< T, X > operator()(index_type index, size_type length) const
Select a subrange of this const array by starting index and length, and return a ArrayViewConst_ refe...
Definition: Array.h:2348
 
const T & at(index_type i) const
Same as operator[] but always range-checked, even in a Release build. 
Definition: Array.h:1092
 
bool operator>(const ArrayViewConst_< T1, X1 > &a1, const ArrayViewConst_< T2, X2 > &a2)
The greater than operator is implemented by using less than with the arguments reversed, meaning the elements must have working comparison operators of the form T2==T1 and T2<T1. 
Definition: Array.h:3713
 
T * insert(T *p, const T &value)
Insert a new element at a given location within this array, initializing it to a copy of a given valu...
Definition: Array.h:2644
 
ArrayIndexPackType< size_type >::packed_size_type packed_size_type
Definition: Array.h:867
 
#define SimTK_ASSERT(cond, msg)
Definition: ExceptionMacros.h:373
 
const T * begin() const
The const version of begin() is the same as cbegin(). 
Definition: Array.h:2214
 
void pop_back()
Remove the last element from this array, which must not be empty. 
Definition: Array.h:2487
 
ArrayIndexTraits< X >::size_type size_type
Definition: Array.h:1544
 
T * raw_push_back()
(Deprecated, use emplace_back() instead) This dangerous non-standard method increases the Array's siz...
Definition: Array.h:2477
 
const T & front() const
Return a const reference to the first element in this array, which must not be empty. 
Definition: Array.h:2323
 
ArrayView_(std::vector< T, A > &v)
Construct to reference memory owned by a writable std::vector. 
Definition: Array.h:889
 
#define SimTK_ERRCHK3(cond, whereChecked, fmt, a1, a2, a3)
Definition: ExceptionMacros.h:330
 
Array_(const std::vector< T2 > &v)
Construct an Array_<T> by copying from an std::vector<T2>, where T2 may be the same type as T but doe...
Definition: Array.h:1636
 
ArrayIndexTraits< X >::size_type size_type
Definition: Array.h:864
 
const T & at(index_type i) const
Same as operator[] but always range-checked, even in a Release build. 
Definition: Array.h:2302
 
ArrayViewConst_(const ArrayViewConst_ &src)
Copy constructor is shallow; the constructed const array object will be referencing the original sour...
Definition: Array.h:384
 
Array_ & adoptData(T *newData, size_type dataSize, size_type dataCapacity)
This dangerous extension allows you to supply your own already-allocated heap space for use by this a...
Definition: Array.h:1994
 
~Array_()
The destructor performs a deallocate() operation which may result in element destruction and freeing ...
Definition: Array.h:1741
 
const T * cdata() const
Return a const pointer to the first element of the array, or possibly (but not necessarily) null (0) ...
Definition: Array.h:672
 
T * begin()
Return a writable pointer to the first element of this array if any, otherwise end(). 
Definition: Array.h:1195
 
ArrayView_ updSubArray(index_type index, size_type length)
Same as non-const operator()(index,length); exists to provide non-operator access to that functionali...
Definition: Array.h:1169
 
ArrayViewConst_()
Default constructor allocates no heap space and is very fast. 
Definition: Array.h:373
 
bool isOwner() const
Definition: Array.h:1268
 
T & reference
A writable value_type reference. 
Definition: Array.h:343
 
T * erase(T *first, const T *last1)
Erase elements in range [first,last1), packing in any later elements into the newly-available space a...
Definition: Array.h:2510
 
const T & getElt(index_type i) const
Same as the const form of operator[]; exists to provide a non-operator method for element access in c...
Definition: Array.h:1102
 
bool isOwner() const
Does this array own the data to which it refers? If not, it can't be resized, and the destructor will...
Definition: Array.h:2194
 
ArrayViewConst_< T, X > getSubArray(index_type index, size_type length) const
Same as const form of operator()(index,length); exists to provide non-operator access to that functio...
Definition: Array.h:2352
 
static std::istream & readArrayFromStream(std::istream &in, Array_< T, X > &out)
Read in an Array_<T> from a stream, as a sequence of space-separated or comma-separated values option...
Definition: Array.h:3589
 
T & operator[](index_type i)
Select an element by its index, returning a writable (lvalue) reference. 
Definition: Array.h:1085
 
X index_type
Definition: Array.h:855
 
Array_ & operator=(const std::vector< T2, A > &src)
This is assignment from a source std::vector<T2>. 
Definition: Array.h:1969
 
This file contains macros which are convenient to use for sprinkling error checking around liberally ...
 
ArrayView_ & operator=(const ArrayView_ &src)
Copy assignment; source must be the same size as this array. 
Definition: Array.h:923
 
Array_(size_type n, const T &initVal)
Construct an array containing n elements each set to a copy of the given initial value. 
Definition: Array.h:1576
 
const_reverse_iterator crbegin() const
Return a const reverse iterator pointing to the last element in the array or crend() if the array is ...
Definition: Array.h:1212
 
This is a compile-time equivalent of "false", used in compile-time condition checking in templatized ...
Definition: SimTKcommon/include/SimTKcommon/internal/common.h:678
 
Array_ & adoptData(T *newData, size_type dataSize)
A variant of adoptData() that assumes the capacity is the same as the current size. 
Definition: Array.h:2016
 
bool empty() const
Definition: Array.h:1265
 
T * erase(T *p)
Erase just one element, moving all subsequent elements down one slot and reducing the array's size by...
Definition: Array.h:2545
 
const T * const_iterator
Definition: Array.h:861
 
const_reverse_iterator rend() const
The const version of rend() is the same as crend(). 
Definition: Array.h:2251
 
T & at(index_type i)
Same as operator[] but always range-checked, even in a Release build. 
Definition: Array.h:1098
 
static const char * name()
The default implementation of name() here returns the raw result from `typeid(T). ...
Definition: SimTKcommon/include/SimTKcommon/internal/common.h:862
 
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition: Array.h:1543
 
ArrayView_ & operator=(const T &fillValue)
Fill assignment – all elements are set to fillValue. 
Definition: Array.h:968
 
const T * begin() const
The const version of begin() is the same as cbegin(). 
Definition: Array.h:648
 
void push_back()
(Deprecated, use emplace_back() instead) This is a non-standard version of push_back() that increases...
Definition: Array.h:2450
 
static std::istream & fillArrayFromStream(std::istream &in, Array_< T, X > &out)
Read in a fixed number of elements from a stream into an Array. 
Definition: Array.h:3619
 
reverse_iterator rbegin()
Return a writable reverse iterator pointing to the last element in the array or rend() if the array i...
Definition: Array.h:1219
 
const T & operator[](index_type i) const
Select an element by its index, returning a const reference. 
Definition: Array.h:1075
 
const_reverse_iterator rbegin() const
The const version of rbegin() is the same as crbegin(). 
Definition: Array.h:2239
 
An element has (1) a tagword, (2) a map of (name,value) pairs called attributes, and (3) a list of ch...
Definition: Xml.h:1033
 
const T & getElt(index_type i) const
Same as the const form of operator[]; exists to provide a non-operator method for element access in c...
Definition: Array.h:568
 
T * insert(T *p, size_type n, const T &value)
Insert n copies of a given value at a particular location within this array, moving all following ele...
Definition: Array.h:2632
 
ArrayIndexTraits< X >::difference_type difference_type
Definition: Array.h:1545
 
void assign(const T2 *first, const T2 *last1)
Assign to this array to make it a copy of the elements in range [first,last1) given by ordinary point...
Definition: Array.h:1013
 
The Array_<T> container class is a plug-compatible replacement for the C++ standard template library ...
Definition: Array.h:53
 
T * end()
Return a writable pointer to what would be the element just after the last one in this array...
Definition: Array.h:1208
 
#define SimTK_ERRCHK_ALWAYS(cond, whereChecked, msg)
Definition: ExceptionMacros.h:281
 
const T * cbegin() const
Return a const pointer to the first element of this array if any, otherwise end(), which may be null (0) in that case but does not have to be. 
Definition: Array.h:1188
 
ArrayIndexPackType< size_type >::packed_size_type packed_size_type
Definition: Array.h:1547
 
ArrayIndexPackType< size_type >::packed_size_type packed_size_type
The integral type we actually use internally to store size_type values. 
Definition: Array.h:361
 
void disconnect()
Forward to base class disconnect() method – clears the handle without doing anything to the data...
Definition: Array.h:901
 
T & front()
Return a writable reference to the first element in this array, which must not be empty...
Definition: Array.h:1121
 
#define SimTK_ERRCHK3_ALWAYS(cond, whereChecked, fmt, a1, a2, a3)
Definition: ExceptionMacros.h:293
 
const T * cdata() const
Return a const pointer to the first element of the array, or possibly (but not necessarily) null (0) ...
Definition: Array.h:2264
 
const T & operator[](index_type i) const
Select an element by its index, returning a const reference. 
Definition: Array.h:554
 
const T & const_reference
Definition: Array.h:859
 
ELEM max(const VectorBase< ELEM > &v)
Definition: VectorMath.h:251
 
std::reverse_iterator< iterator > reverse_iterator
Definition: Array.h:862
 
const T * cend() const
Return a const pointer to what would be the element just after the last one in the array; this may be...
Definition: Array.h:1201
 
ArrayView_ & operator=(const Array_< T2, X2 > &src)
Assignment from any other array object is allowed as long as the number of elements matches and the t...
Definition: Array.h:954
 
T * data()
Return a writable pointer to the first allocated element of the array, or a null pointer if no space ...
Definition: Array.h:1247
 
const T * const_pointer
Definition: Array.h:1537
 
void assign(size_type n, const T &fillValue)
This is the same as fill() but has the usual std::vector signature for compatibility; it will only wo...
Definition: Array.h:985
 
const T * const_pointer
A const pointer to a value_type. 
Definition: Array.h:341
 
bool operator>=(const ArrayViewConst_< T1, X1 > &a1, const ArrayViewConst_< T2, X2 > &a2)
The greater than or equal operator is implemented using the less than operator. 
Definition: Array.h:3707
 
void reserve(size_type n)
Ensure that this array has enough allocated capacity to hold the indicated number of elements...
Definition: Array.h:2136
 
T value_type
Definition: Array.h:1534
 
const_reverse_iterator rbegin() const
The const version of rbegin() is the same as crbegin(). 
Definition: Array.h:1215
 
bool operator!=(const ArrayViewConst_< T1, X1 > &a1, const std::vector< T2, A2 > &v2)
The not equal operator is implemented using the equal operator. 
Definition: Array.h:3738
 
const T * data() const
The const version of the data() method is identical to cdata(). 
Definition: Array.h:1243
 
const T & const_reference
Definition: Array.h:1539
 
ArrayIndexTraits< X >::difference_type difference_type
Definition: Array.h:865
 
size_type allocated() const
Return the amount of heap space owned by this array; this is the same as capacity() for owner arrays ...
Definition: Array.h:2187
 
#define SimTK_FORCE_INLINE
Definition: SimTKcommon/include/SimTKcommon/internal/common.h:269
 
std::ostream & operator<<(std::ostream &o, const ContactForce &f)
Definition: CompliantContactSubsystem.h:387
 
bool operator>(const std::vector< T1, A1 > &v1, const ArrayViewConst_< T2, X2 > &a2)
The greater than operator is implemented by using less than with the arguments reversed, meaning the elements must have working comparison operators of the form T2==T1 and T2<T1. 
Definition: Array.h:3785
 
std::reverse_iterator< iterator > reverse_iterator
A writable reverse iterator for this container. 
Definition: Array.h:351
 
bool empty() const
Return true if there are no elements currently stored in this array. 
Definition: Array.h:519
 
Array_ & operator=(Array_ &&src)
Move assignment operator swaps the contents of this Array_ with the source Array_. 
Definition: Array.h:1945
 
void swap(Array_ &other)
This is a specialized algorithm providing constant time exchange of data with another array that has ...
Definition: Array.h:1983
 
#define SimTK_INDEXCHECK_ALWAYS(ix, ub, where)
Definition: ExceptionMacros.h:106
 
void writeFormatted(std::ostream &o, const Array_< T, X > &v)
Specialize writeFormatted() for Array_<E,X> to delegate to element type E, with surrounding parenthes...
Definition: Array.h:3484
 
#define SimTK_ERRCHK(cond, whereChecked, msg)
Definition: ExceptionMacros.h:324
 
T * end()
Return a writable pointer to what would be the element just after the last one in this array...
Definition: Array.h:2232
 
Array_(std::initializer_list< T > ilist)
Construct an Array_<T> from an std::initializer_list whose elements were convertible to type T...
Definition: Array.h:1628
 
#define SimTK_ERRCHK2(cond, whereChecked, fmt, a1, a2)
Definition: ExceptionMacros.h:328
 
const T * end() const
The const version of end() is the same as cend(). 
Definition: Array.h:2227
 
This Array_ helper class is the base class for ArrayView_ which is the base class for Array_; here we...
Definition: Array.h:51
 
T & back()
Return a writable reference to the last element in this array, which must not be empty. 
Definition: Array.h:2344
 
const T & back() const
Return a const reference to the last element in this array, which must not be empty (we'll check in a...
Definition: Array.h:585
 
Array_()
Default constructor allocates no heap space and is very fast. 
Definition: Array.h:1560
 
void swap(SimTK::Array_< T, X > &a1, SimTK::Array_< T, X > &a2)
This is a specialization of the STL std::swap() algorithm which uses the constant time built-in swap(...
Definition: Array.h:3808
 
size_type size() const
Definition: Array.h:1263
 
Array_(T *first, const T *last1, const DontCopy &)
Construct an Array_<T> by referencing (sharing) a given range of data [first,last1), without copying that data; better to use the corresponding ArrayView_<T> constructor if you can. 
Definition: Array.h:1706
 
bool operator>=(const ArrayViewConst_< T1, X1 > &a1, const std::vector< T2, A2 > &v2)
The greater than or equal operator is implemented using the less than operator. 
Definition: Array.h:3767
 
Mandatory first inclusion for any Simbody source or header file. 
 
reverse_iterator rend()
Return a writable past-the-end reverse iterator that tests equal to a reverse iterator that has been ...
Definition: Array.h:2256
 
X index_type
Definition: Array.h:1535
 
Array_ & deallocate()
Empty this array of its contents, returning the array to its default-constructed, all-zero state...
Definition: Array.h:1753
 
This file contains definitions of templatized serialize-to-stream methods specialized for the built-i...
 
void clear()
Erase all the elements currently in this array without changing the capacity; equivalent to erase(beg...
Definition: Array.h:2598
 
const_reverse_iterator crbegin() const
Return a const reverse iterator pointing to the last element in the array or crend() if the array is ...
Definition: Array.h:654
 
#define SimTK_INDEXCHECK(ix, ub, where)
Definition: ExceptionMacros.h:145
 
ArrayViewConst_(const T *first, const T *last1)
Construct an ArrayViewConst_<T> by referencing (sharing) a given range of const data [first...
Definition: Array.h:413
 
const T * end() const
The const version of end() is the same as cend(). 
Definition: Array.h:650
 
X index_type
The index type (an extension). 
Definition: Array.h:337
 
T * iterator
Definition: Array.h:1540
 
bool operator==(const ArrayViewConst_< T1, X1 > &a1, const ArrayViewConst_< T2, X2 > &a2)
Two Array_ objects are equal if and only if they are the same size() and each element compares equal ...
Definition: Array.h:3670
 
ArrayViewConst_ getSubArray(index_type index, size_type length) const
Same as const form of operator()(index,length); exists to provide non-operator access to that functio...
Definition: Array.h:621
 
ArrayIndexTraits< X >::size_type size_type
An integral type suitable for all indices and sizes for this array. 
Definition: Array.h:355
 
void assign(const Iter &first, const Iter &last1)
Assign to this array to make it a copy of the elements in range [first,last1) given by non-pointer it...
Definition: Array.h:1055
 
Array_(const Array_ &src)
Copy constructor allocates exactly as much memory as is in use in the source (not its capacity) and c...
Definition: Array.h:1654
 
T & updElt(index_type i)
Same as the non-const form of operator[]; exists to provide a non-operator method for element access ...
Definition: Array.h:1106
 
const T * cend() const
Return a const pointer to what would be the element just after the last one in the array; this may be...
Definition: Array.h:2225
 
const T * const_pointer
Definition: Array.h:857
 
std::istream & operator>>(std::istream &in, ArrayView_< T, X > &out)
Read a (fixed size n) ArrayView_<T> from a stream as a sequence of space- or comma-separated values o...
Definition: Array.h:3654
 
size_type allocated() const
Definition: Array.h:1267
 
const T * const_iterator
Definition: Array.h:1541
 
size_type max_size() const
Definition: Array.h:1264
 
bool operator!=(const ArrayViewConst_< T1, X1 > &a1, const ArrayViewConst_< T2, X2 > &a2)
The not equal operator is implemented using the equal operator. 
Definition: Array.h:3684
 
T * begin()
Return a writable pointer to the first element of this array if any, otherwise end(). 
Definition: Array.h:2219
 
T * insert(T *p, const Iter &first, const Iter &last1)
Insert elements in a range [first,last1) where the range is given by non-pointer iterators. 
Definition: Array.h:2711
 
T & reference
Definition: Array.h:858
 
reverse_iterator rend()
Return a writable past-the-end reverse iterator that tests equal to a reverse iterator that has been ...
Definition: Array.h:1232
 
bool readFormatted(std::istream &in, ArrayView_< T, X > &v)
Specialization of readFormatted() for fixed-length ArrayView_<T,X>; uses fillArrayViewFromStream() to...
Definition: Array.h:3555
 
const T * const_iterator
A const iterator for this container (same as const_pointer here). 
Definition: Array.h:349
 
ArrayView_ & fill(const T &fillValue)
Assign the supplied fill value to each element of this array, using T's copy assignment operator for ...
Definition: Array.h:976
 
T * eraseFast(T *p)
Be careful with this non-standard extension; it erases one element and then moves the last one in its...
Definition: Array.h:2578
 
void disconnect()
Disconnect this array handle from any data to which it refers, restoring it to the condition it would...
Definition: Array.h:489
 
ArrayView_< T, X > updSubArray(index_type index, size_type length)
Same as non-const operator()(index,length); exists to provide non-operator access to that functionali...
Definition: Array.h:2361
 
Array_(std::vector< T, A > &v, const DontCopy &)
Construct an Array_<T> by referencing (sharing) the data in an std::vector<T>, without copying the da...
Definition: Array.h:1736
 
void resize(size_type n, const T &initVal)
Change the size of this array, preserving all the elements that will still fit, and initializing any ...
Definition: Array.h:2113
 
bool operator>=(const std::vector< T1, A1 > &v1, const ArrayViewConst_< T2, X2 > &a2)
The greater than or equal operator is implemented using the less than operator. 
Definition: Array.h:3772
 
const T * cbegin() const
Return a const pointer to the first element of this array if any, otherwise cend(), which may be null (0) in that case but does not have to be. 
Definition: Array.h:641
 
T & front()
Return a writable reference to the first element in this array, which must not be empty...
Definition: Array.h:2330
 
ArrayView_ operator()(index_type index, size_type length)
Select a contiguous subarray of the elements of this array and create another ArrayView_ that refers ...
Definition: Array.h:1155
 
const T * cdata() const
Return a const pointer to the first element of the array, or possibly (but not necessarily) null (0) ...
Definition: Array.h:1240
 
ArrayView_ & operator=(const ArrayView_< T2, X2 > &src)
Assignment from any other array object is allowed as long as the number of elements matches and the t...
Definition: Array.h:949
 
void shrink_to_fit()
Request that the capacity of this array be reduced to the minimum necessary to hold the number of ele...
Definition: Array.h:2172
 
Array_ & operator=(const Array_ &src)
Copy assignment operator destructs the current contents of this array and then makes it a copy of the...
Definition: Array.h:1935
 
void push_back(const T &value)
This method increases the size of the Array by one element at the end and initializes that element by...
Definition: Array.h:2399
 
T & updElt(index_type i)
Same as the non-const form of operator[]; exists to provide a non-operator method for element access ...
Definition: Array.h:2316
 
size_type capacity() const
Definition: Array.h:1266
 
bool readFormatted(std::istream &in, Array_< T, X > &v)
Specialization of readFormatted() for variable-length Array_<T,X>; uses readArrayFromStream() to cons...
Definition: Array.h:3545
 
std::reverse_iterator< const_iterator > const_reverse_iterator
A const reverse iterator for this container. 
Definition: Array.h:353
 
Array_ & shareData(T *newData, size_type dataSize)
This dangerous extension allows you to make this array handle refer to someone else's data without co...
Definition: Array.h:2033
 
T & operator[](index_type i)
Select an element by its index, returning a writable (lvalue) reference. 
Definition: Array.h:2296
 
bool operator==(const std::vector< T1, A1 > &v1, const ArrayViewConst_< T2, X2 > &a2)
An std::vector<T1> and an Array_<T2> are equal if and only if they are the same size() and each eleme...
Definition: Array.h:3732
 
const_reverse_iterator rend() const
The const version of rend() is the same as crend(). 
Definition: Array.h:664
 
~ArrayView_()
The destructor just disconnects the array view handle from its data; see ArrayViewConst_<T,X>::disconnect() for more information. 
Definition: Array.h:905
 
const_reverse_iterator crend() const
Return the past-the-end reverse iterator that tests equal to a reverse iterator that has been increme...
Definition: Array.h:659
 
T * emplace(T *p, Args &&... args)
Insert a new element at a given location within this array, by invoking T's constructor whose signatu...
Definition: Array.h:2658
 
size_type capacity() const
Return the number of elements this array can currently hold without requiring reallocation. 
Definition: Array.h:2085
 
T * pointer
Definition: Array.h:856
 
ArrayView_(T *first, const T *last1)
Construct from a range of writable memory. 
Definition: Array.h:885
 
void assign(const Iter &first, const Iter &last1)
Assign this array from a range [first,last1) given by non-pointer iterators. 
Definition: Array.h:1925
 
Array_ & shareData(T *first, const T *last1)
Same as shareData(data,size) but uses a pointer range [first,last1) to identify the data to be refere...
Definition: Array.h:2050
 
T * data()
Return a writable pointer to the first allocated element of the array, or a null pointer if no space ...
Definition: Array.h:2271
 
ArrayView_< T, X > operator()(index_type index, size_type length)
Select a subrange of this array by starting index and length, and return an ArrayView_ referencing th...
Definition: Array.h:2357
 
bool isSizeInRange(char sz, char mx)
Definition: SimTKcommon/include/SimTKcommon/internal/common.h:338
 
static std::istream & readArrayFromStreamHelper(std::istream &in, bool isFixedSize, Array_< T, X > &out)
Definition: Array.h:3281
 
const T & back() const
Return a const reference to the last element in this array, which must not be empty. 
Definition: Array.h:2337
 
static std::istream & fillArrayViewFromStream(std::istream &in, ArrayView_< T, X > &out)
Read in a fixed number of elements from a stream into an ArrayView. 
Definition: Array.h:3627
 
std::istream & operator>>(std::istream &in, Array_< T, X > &out)
Read an Array_<T> from a stream as a sequence of space- or comma-separated values of type T...
Definition: Array.h:3643
 
const T & front() const
Return a const reference to the first element in this array, which must not be empty (we'll check in ...
Definition: Array.h:577
 
const T * cend() const
Return a const pointer to what would be the element just after the last one in the array; this may be...
Definition: Array.h:646
 
size_type allocated() const
Return the amount of heap space owned by this array; this is the same as capacity() for owner arrays ...
Definition: Array.h:529
 
ArrayView_(const ArrayView_ &src)
Copy constructor is shallow. 
Definition: Array.h:882
 
void emplace_back(Args &&... args)
This is similar to push_back() but rather than copying, it constructs the element in place at the end...
Definition: Array.h:2426
 
const_reverse_iterator rend() const
The const version of rend() is the same as crend(). 
Definition: Array.h:1227
 
const_reverse_iterator crbegin() const
Return a const reverse iterator pointing to the last element in the array or crend() if the array is ...
Definition: Array.h:2236
 
Array_(const T2 *first, const T2 *last1)
Construct an Array_<T> from a range [first,last1) of values identified by a pair of ordinary pointers...
Definition: Array.h:1608
 
T * insert(T *p, const T2 *first, const T2 *last1)
Insert elements in a range [first,last1) into this array at a given position p, moving all following ...
Definition: Array.h:2696
 
size_type max_size() const
Return the maximum allowable size for this array. 
Definition: Array.h:515
 
ArrayView_ & operator=(const std::vector< T2, A2 > &src)
Assignment from any std::vector object is allowed as long as the number of elements matches and the t...
Definition: Array.h:960