Advertisement
Guest User

Copy on write C++ example

a guest
Mar 28th, 2014
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. copy_on_write<std::vector<EnvelopePoint>> envelope1;
  2. envelope1.write().push_back(EnvelopePoint(0.0,1.0));
  3. envelope1.write().push_back(EnvelopePoint(1.0,0.0));
  4. std::vector<copy_on_write<std::vector<EnvelopePoint>>> copies;
  5. for (int i=0;i<1000000;i++) // some tests i've done actually involve a million HourGlass envelopes and it seems to work fine
  6. {
  7.   copies.push_back(envelope1);  
  8. }
  9. // from the 5000th copy of the envelope, read second point's time position
  10. qDebug() << copies[5000].read()[1].TimePosition();
  11. // change time position of the first node of the 999999th copy of the envelope
  12. copies[999998].write()[0].setTimePosition(0.13);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement