本文整理汇总了C++中Array_::shareData方法的典型用法代码示例。如果您正苦于以下问题:C++ Array_::shareData方法的具体用法?C++ Array_::shareData怎么用?C++ Array_::shareData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Array_
的用法示例。
在下文中一共展示了Array_::shareData方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testConstruction
void testConstruction() {
const int data[] = {5,3,-2,27,9};
const char uchar[] = {'f','i','t','z'};
Array_<int> nothing;
Array_<int> def(5);
Array_<int> intWithInt(data, data+5);
Array_<char> charWithChar(uchar, uchar+4);
Array_<int> intWithChar(uchar, uchar+4);
Array_<char> charWithInt(data, data+5);
cout << "nothing=" << nothing << endl;
cout << "def=" << def << endl;
cout << "intWithInt=" << intWithInt << endl;
cout << "charWithChar=" << charWithChar << endl;
cout << "intWithChar=" << intWithChar << endl;
cout << "charWithInt=" << charWithInt << endl;
Array_< Count<int> > cint(data, data+5);
Count<int>::dumpCounts("cint(data,data+5)");
Count<int>::reset();
const Count<int> counts[] = {3,4,5};
Count<int>::reset();
Array_< Count<int> > ccnt(counts, counts+3);
Count<int>::dumpCounts("ccnt(counts,counts+3)");
Count<int>::reset();
Array_< Count<int> > cint2(cint);
Count<int>::dumpCounts("cint2(cint)");
Count<int>::reset();
cint2 = ccnt;
Count<int>::dumpCounts("cint2=ccnt");
Count<int>::reset();
cout << "cint2=" << cint2 << endl;
Array_<int,SmallIx> ismall0;
cout << "default constructed Array_<int> begin()=" << ismall0.begin()
<< " end()=" << ismall0.end()
<< " capacity()=" << (int)ismall0.capacity()
<< endl;
std::vector<int> ivec0;
cout << "default constructed std::vector<int>"
<< " capacity()=" << ivec0.capacity()
<< endl;
Array_<int,SmallIx> ismall(3);
Array_<int,SmallIx> imaxsz(data, data+4);
cout << "ismall0=" << ismall0 << endl;
cout << "ismall=" << ismall << endl;
cout << "imaxsz=" << imaxsz << endl;
new(ismall.raw_push_back()) int(27);
cout << "ismall after raw_push_back():" << ismall << endl;
SimTK_TEST_MUST_THROW_DEBUG(imaxsz.push_back()); // already full
// Check null assignments.
ismall = ismall0; // src is null
ismall0 = imaxsz; // dest was null
ismall = Array_<int,SmallIx>(); // both null
cout << "sizeof(Array_<int,bool>)=" << sizeof(Array_<int,bool>) << endl;
cout << "sizeof(Array_<int,char>)=" << sizeof(Array_<int,unsigned char>) << endl;
cout << "sizeof(Array_<int,short>)=" << sizeof(Array_<int,unsigned short>) << endl;
cout << "sizeof(Array_<int>)=" << sizeof(Array_<int>) << endl;
cout << "sizeof(std::vector<int>)=" << sizeof(std::vector<int>) << endl;
cout << "sizeof(Array_<int,long long>)=" << sizeof(Array_<int,long long>) << endl;
Array_<String, TestIx> strings(6, "woohoo");
cout << "strings=" << strings << endl;
strings.push_back("last");
for (int i=0; i<5; ++i) {
strings.insert(strings.end(), 2, "ins" + String(i));
cout << strings.size() << ":" << strings.capacity()
<< ":" << strings << endl;
}
cout << "strings=" << strings << endl;
Array_<String, TestIx>::reverse_iterator p = strings.rbegin();
while (p != strings.rend())
cout << " " << *p++;
cout << endl;
const int ownerData[] = {7, 77, 777, 7777, 77777};
std::vector<int> owner(ownerData, ownerData+5);
std::vector<unsigned> unowner(owner.begin(), owner.end());
Array_<int> shared; shared.shareData(&owner[1], &owner[4]);
cout << "vector before=" << owner << endl;
cout << "shared before=" << shared << endl;
shared[2] = 29;
cout << "shared after=" << shared << endl;
cout << "vector after=" << owner << endl;
cout << "shared(1,2)=" << shared(1,2) << endl;
Array_<int> copyOfOwner(owner);
cout << "copyOfOwner=" << copyOfOwner << endl;
Array_<unsigned short,char> weirdCopy(owner);
cout << "weirdCopy=" << weirdCopy << endl;
copyOfOwner = unowner;
//.........这里部分代码省略.........