vector_vs.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758
  1. ////////////////////////////////////////////////////////////////////////////////////////
  2. // RAVEN STANDARD TEMPLATE LIBRARY
  3. // (c) 2002 Activision
  4. //
  5. //
  6. // Vector
  7. // ------
  8. // The vector class is a simple addition to the array. It supports some useful additions
  9. // like sort and binary search, as well as keeping track of the number of objects
  10. // contained within.
  11. //
  12. //
  13. //
  14. //
  15. //
  16. // NOTES:
  17. //
  18. //
  19. ////////////////////////////////////////////////////////////////////////////////////////
  20. #if !defined(RATL_VECTOR_VS_INC)
  21. #define RATL_VECTOR_VS_INC
  22. ////////////////////////////////////////////////////////////////////////////////////////
  23. // Includes
  24. ////////////////////////////////////////////////////////////////////////////////////////
  25. #if !defined(RATL_COMMON_INC)
  26. #include "ratl_common.h"
  27. #endif
  28. namespace ratl
  29. {
  30. ////////////////////////////////////////////////////////////////////////////////////////
  31. // The Vector Class
  32. ////////////////////////////////////////////////////////////////////////////////////////
  33. template<class T>
  34. class vector_base : public ratl_base
  35. {
  36. public:
  37. typedef typename T TStorageTraits;
  38. typedef typename T::TValue TTValue;
  39. ////////////////////////////////////////////////////////////////////////////////////
  40. // Capacity Enum
  41. ////////////////////////////////////////////////////////////////////////////////////
  42. enum
  43. {
  44. CAPACITY = T::CAPACITY
  45. };
  46. private:
  47. array_base<TStorageTraits> mArray; // The Memory
  48. int mSize;
  49. public:
  50. ////////////////////////////////////////////////////////////////////////////////////
  51. // Constructor
  52. ////////////////////////////////////////////////////////////////////////////////////
  53. vector_base()
  54. {
  55. mSize = 0;
  56. }
  57. ////////////////////////////////////////////////////////////////////////////////////
  58. // Copy Constructor
  59. ////////////////////////////////////////////////////////////////////////////////////
  60. vector_base(const vector_base &B)
  61. {
  62. for (int i=0; i<B.size(); i++)
  63. {
  64. mArray[i] = B.mArray[i];
  65. }
  66. mSize = val.mSize;
  67. }
  68. ////////////////////////////////////////////////////////////////////////////////////
  69. // How Many Objects Can Be Added?
  70. ////////////////////////////////////////////////////////////////////////////////////
  71. int capacity() const
  72. {
  73. assert(mSize>=0&&mSize<=CAPACITY);
  74. return (CAPACITY);
  75. }
  76. ////////////////////////////////////////////////////////////////////////////////////
  77. // How Many Objects Have Been Added To This Vector?
  78. ////////////////////////////////////////////////////////////////////////////////////
  79. int size() const
  80. {
  81. assert(mSize>=0&&mSize<=CAPACITY);
  82. return (mSize);
  83. }
  84. ////////////////////////////////////////////////////////////////////////////////////
  85. // Have Any Objects Have Been Added To This Vector?
  86. ////////////////////////////////////////////////////////////////////////////////////
  87. bool empty() const
  88. {
  89. assert(mSize>=0&&mSize<=CAPACITY);
  90. return (!mSize);
  91. }
  92. ////////////////////////////////////////////////////////////////////////////////////
  93. // Have Any Objects Have Been Added To This Vector?
  94. ////////////////////////////////////////////////////////////////////////////////////
  95. bool full() const
  96. {
  97. assert(mSize>=0&&mSize<=CAPACITY);
  98. return (mSize==CAPACITY);
  99. }
  100. ////////////////////////////////////////////////////////////////////////////////////
  101. // Clear Out Entire Array
  102. ////////////////////////////////////////////////////////////////////////////////////
  103. void clear()
  104. {
  105. mArray.clear();
  106. mSize = 0;
  107. }
  108. // Constant Access Operator
  109. ////////////////////////////////////////////////////////////////////////////////////
  110. const TTValue& operator[](int index) const
  111. {
  112. assert(index>=0&&index<mSize);
  113. return mArray[index];
  114. }
  115. ////////////////////////////////////////////////////////////////////////////////////
  116. // Access Operator
  117. ////////////////////////////////////////////////////////////////////////////////////
  118. TTValue& operator[](int index)
  119. {
  120. assert(index>=0&&index<mSize);
  121. return mArray[index];
  122. }
  123. ////////////////////////////////////////////////////////////////////////////////////
  124. // Access To The Raw Array Pointer
  125. ////////////////////////////////////////////////////////////////////////////////////
  126. TTValue * raw_array()
  127. {
  128. // this (intentionally) won't compile for anything except value semantics
  129. // could be done with object semantics, but I would want to assert that all objects are contructed
  130. return T::raw_array(mArray);
  131. }
  132. ////////////////////////////////////////////////////////////////////////////////////
  133. // Access To The Raw Array Pointer
  134. ////////////////////////////////////////////////////////////////////////////////////
  135. const TTValue* raw_array() const
  136. {
  137. // this (intentionally) won't compile for anything except value semantics
  138. // could be done with object semantics, but I would want to assert that all objects are contructed
  139. return T::raw_array(mArray);
  140. }
  141. ////////////////////////////////////////////////////////////////////////////////////
  142. // Assignment Operator
  143. ////////////////////////////////////////////////////////////////////////////////////
  144. vector_base& operator=(const vector_base& val)
  145. {
  146. for (int i=0; i<val.size(); i++)
  147. {
  148. mArray[i] = val.mArray[i];
  149. }
  150. mSize = val.mSize;
  151. return *this;
  152. }
  153. ////////////////////////////////////////////////////////////////////////////////////
  154. // Add
  155. ////////////////////////////////////////////////////////////////////////////////////
  156. TTValue & push_back()
  157. {
  158. assert(mSize>=0&&mSize<CAPACITY);
  159. mArray.construct(mSize);
  160. mSize++;
  161. return (mArray[mSize-1]);
  162. }
  163. ////////////////////////////////////////////////////////////////////////////////////
  164. // Add (And Set)
  165. ////////////////////////////////////////////////////////////////////////////////////
  166. void push_back(const TTValue& value)
  167. {
  168. assert(mSize>=0&&mSize<CAPACITY);
  169. mArray.construct(mSize,value);
  170. mSize++;
  171. }
  172. ////////////////////////////////////////////////////////////////////////////////////
  173. // Add raw
  174. ////////////////////////////////////////////////////////////////////////////////////
  175. TRatlNew * push_back_raw()
  176. {
  177. assert(mSize>=0&&mSize<CAPACITY);
  178. mSize++;
  179. return mArray.alloc_raw(mSize-1);
  180. }
  181. ////////////////////////////////////////////////////////////////////////////////////
  182. // Remove
  183. ////////////////////////////////////////////////////////////////////////////////////
  184. void pop_back()
  185. {
  186. assert(mSize>0);
  187. mSize--;
  188. mArray.destruct(mSize);
  189. }
  190. ////////////////////////////////////////////////////////////////////////////////////
  191. // Resizes The Array. If New Elements Are Needed, It Uses The (value) Param
  192. ////////////////////////////////////////////////////////////////////////////////////
  193. void resize(int nSize, const TTValue& value)
  194. {
  195. int i;
  196. for (i=(mSize-1); i>=nSize; i--)
  197. {
  198. mArray.destruct(i);
  199. mSize--;
  200. }
  201. for (i=mSize; i<nSize; i++)
  202. {
  203. mArray.construct(i,value);
  204. }
  205. mSize = nSize;
  206. }
  207. ////////////////////////////////////////////////////////////////////////////////////
  208. // Resizes The Array. If New Elements Are Needed, It Uses The (value) Param
  209. ////////////////////////////////////////////////////////////////////////////////////
  210. void resize(int nSize)
  211. {
  212. int i;
  213. for (i=mSize-1; i>=nSize; i--)
  214. {
  215. mArray.destruct(i);
  216. mSize--;
  217. }
  218. for (i=mSize; i<nSize; i++)
  219. {
  220. mArray.construct(i);
  221. }
  222. mSize = nSize;
  223. }
  224. ////////////////////////////////////////////////////////////////////////////////////
  225. // Swap the values at two locations
  226. ////////////////////////////////////////////////////////////////////////////////////
  227. void swap(int i,int j)
  228. {
  229. assert(i<mSize && j<mSize);
  230. mArray.swap(i, j);
  231. }
  232. ////////////////////////////////////////////////////////////////////////////////////
  233. // Erase An Iterator Location... NOTE: THIS DOES NOT PRESERVE ORDER IN THE VECTOR!!
  234. ////////////////////////////////////////////////////////////////////////////////////
  235. void erase_swap(int Index)
  236. {
  237. assert(Index>=0 && Index<mSize);
  238. if (Index != mSize - 1)
  239. {
  240. mArray.swap(Index, mSize - 1);
  241. }
  242. pop_back();
  243. }
  244. ////////////////////////////////////////////////////////////////////////////////////
  245. // Binary Search
  246. ////////////////////////////////////////////////////////////////////////////////////
  247. int find_index(const TTValue& value) const
  248. {
  249. int base = 0;
  250. int head = mSize-1;
  251. while (1)
  252. {
  253. int searchAt = (base+head)/2;
  254. if (base == head && searchAt == head)
  255. {
  256. break;
  257. }
  258. if (value < mArray[searchAt])
  259. {
  260. head = searchAt-1;
  261. }
  262. else if (mArray[searchAt] < value)
  263. {
  264. base = searchAt;
  265. }
  266. else
  267. {
  268. return searchAt;
  269. }
  270. if (head < base)
  271. {
  272. break;
  273. }
  274. }
  275. return mSize; //not found!
  276. }
  277. ////////////////////////////////////////////////////////////////////////////////////
  278. // Heap Sort
  279. //
  280. // This sort algorithm has all the advantages of merge sort in terms of guarenteeing
  281. // O(n log n) worst case, as well as all the advantages of quick sort in that it is
  282. // "in place" and requires no additional storage.
  283. //
  284. ////////////////////////////////////////////////////////////////////////////////////
  285. void sort()
  286. {
  287. // Temporary Data
  288. //----------------
  289. int HeapSize; // How Large The Heap Is (Grows In PHASE 1, Shrinks In PHASE 2)
  290. int Pos; // The Location We Are AT During "re-heapify" Loops
  291. int Compare; // The Location We Are Comparing AGAINST During "re-heapify" Loops
  292. // PHASE 1, CONSTRUCT THE HEAP O(n log n)
  293. //===============================================================================
  294. for (HeapSize=1; HeapSize<mSize; HeapSize++)
  295. {
  296. // We Now Have An Element At Heap Size Which Is Not In It's Correct Place
  297. //------------------------------------------------------------------------
  298. Pos = HeapSize;
  299. Compare = parent(Pos);
  300. while (mArray[Compare]<mArray[Pos])
  301. {
  302. // Swap The Compare Element With The Pos Element
  303. //-----------------------------------------------
  304. mArray.swap(Compare, Pos);
  305. // Move Pos To The Current Compare, And Recalc Compare
  306. //------------------------------------------------------
  307. Pos = Compare;
  308. Compare = parent(Pos);
  309. }
  310. }
  311. // PHASE 2, POP OFF THE TOP OF THE HEAP ONE AT A TIME (AND FIX) O(n log n)
  312. //===============================================================================
  313. for (HeapSize=(mSize-1); HeapSize>0; HeapSize--)
  314. {
  315. // Swap The End And Front Of The "Heap" Half Of The Array
  316. //--------------------------------------------------------
  317. mArray.swap(0, HeapSize);
  318. // We Now Have A Bogus Element At The Root, So Fix The Heap
  319. //----------------------------------------------------------
  320. Pos = 0;
  321. Compare = largest_child(Pos, HeapSize);
  322. while (mArray[Pos]<mArray[Compare])
  323. {
  324. // Swap The Compare Element With The Pos Element
  325. //-----------------------------------------------
  326. mArray.swap(Compare, Pos);
  327. // Move Pos To The Current Compare, And Recalc Compare
  328. //------------------------------------------------------
  329. Pos = Compare;
  330. Compare = largest_child(Pos, HeapSize);
  331. }
  332. }
  333. }
  334. ////////////////////////////////////////////////////////////////////////////////////
  335. // THIS IS A QUICK VALIDATION OF A SORTED LIST
  336. ////////////////////////////////////////////////////////////////////////////////////
  337. #ifdef _DEBUG
  338. void sort_validate() const
  339. {
  340. for (int a=0; a<(mSize-1); a++)
  341. {
  342. assert(mArray[a] < mArray[a+1]);
  343. }
  344. }
  345. #endif
  346. private:
  347. ////////////////////////////////////////////////////////////////////////////////////
  348. // For Heap Sort
  349. // Returns The Location Of Node (i)'s Parent Node (The Parent Node Of Zero Is Zero)
  350. ////////////////////////////////////////////////////////////////////////////////////
  351. static int parent(int i)
  352. {
  353. return ((i-1)/2);
  354. }
  355. ////////////////////////////////////////////////////////////////////////////////////
  356. // For Heap Sort
  357. // Returns The Location Of Node (i)'s Left Child (The Child Of A Leaf Is The Leaf)
  358. ////////////////////////////////////////////////////////////////////////////////////
  359. static int left(int i)
  360. {
  361. return ((2*i)+1);
  362. }
  363. ////////////////////////////////////////////////////////////////////////////////////
  364. // For Heap Sort
  365. // Returns The Location Of Node (i)'s Right Child (The Child Of A Leaf Is The Leaf)
  366. ////////////////////////////////////////////////////////////////////////////////////
  367. static int right(int i)
  368. {
  369. return ((2*i)+2);
  370. }
  371. ////////////////////////////////////////////////////////////////////////////////////
  372. // For Heap Sort
  373. // Returns The Location Of Largest Child Of Node (i)
  374. ////////////////////////////////////////////////////////////////////////////////////
  375. int largest_child(int i, int Size) const
  376. {
  377. if (left(i)<Size)
  378. {
  379. if (right(i)<Size)
  380. {
  381. return ( (mArray[right(i)] < mArray[left(i)]) ? (left(i)) : (right(i)) );
  382. }
  383. return left(i); // Node i only has a left child, so by default it is the biggest
  384. }
  385. return i; // Node i is a leaf, so just return it
  386. }
  387. public:
  388. ////////////////////////////////////////////////////////////////////////////////////
  389. // Iterator
  390. ////////////////////////////////////////////////////////////////////////////////////
  391. class const_iterator;
  392. class iterator
  393. {
  394. friend class vector_base<T>;
  395. friend class const_iterator;
  396. // Data
  397. //------
  398. int mLoc;
  399. vector_base<T>* mOwner;
  400. public:
  401. // Constructors
  402. //--------------
  403. iterator() : mOwner(0), mLoc(0)
  404. {}
  405. iterator(vector_base<T>* p, int t) : mOwner(p), mLoc(t)
  406. {}
  407. iterator(const iterator &t) : mOwner(t.mOwner), mLoc(t.mLoc)
  408. {}
  409. // Assignment Operator
  410. //---------------------
  411. void operator= (const iterator &t)
  412. {
  413. mOwner = t.mOwner;
  414. mLoc = t.mLoc;
  415. }
  416. // Equality Operators
  417. //--------------------
  418. bool operator!=(const iterator &t) const
  419. {
  420. return (mLoc!=t.mLoc || mOwner!=t.mOwner);
  421. }
  422. bool operator==(const iterator &t) const
  423. {
  424. return (mLoc==t.mLoc && mOwner==t.mOwner);
  425. }
  426. // DeReference Operator
  427. //----------------------
  428. TTValue& operator* () const
  429. {
  430. assert(mLoc>=0 && mLoc<mOwner->mSize);
  431. return (mOwner->mArray[mLoc]);
  432. }
  433. // DeReference Operator
  434. //----------------------
  435. TTValue& value() const
  436. {
  437. assert(mLoc>=0 && mLoc<mOwner->mSize);
  438. return (mOwner->mArray[mLoc]);
  439. }
  440. // DeReference Operator
  441. //----------------------
  442. TTValue* operator-> () const
  443. {
  444. assert(mLoc>=0 && mLoc<mOwner->mSize);
  445. return (&mOwner->mArray[mLoc]);
  446. }
  447. // Inc Operator
  448. //--------------
  449. iterator operator++(int) //postfix
  450. {
  451. assert(mLoc>=0 && mLoc<mOwner->mSize);
  452. iterator old(*this);
  453. mLoc ++;
  454. return old;
  455. }
  456. // Inc Operator
  457. //--------------
  458. iterator operator++()
  459. {
  460. assert(mLoc>=0 && mLoc<mOwner->mSize);
  461. mLoc ++;
  462. return *this;
  463. }
  464. };
  465. ////////////////////////////////////////////////////////////////////////////////////
  466. // Constant Iterator
  467. ////////////////////////////////////////////////////////////////////////////////////
  468. class const_iterator
  469. {
  470. friend class vector_base<T>;
  471. int mLoc;
  472. const vector_base<T>* mOwner;
  473. public:
  474. // Constructors
  475. //--------------
  476. const_iterator() : mOwner(0), mLoc(0)
  477. {}
  478. const_iterator(const vector_base<T>* p, int t) : mOwner(p), mLoc(t)
  479. {}
  480. const_iterator(const const_iterator &t) : mOwner(t.mOwner), mLoc(t.mLoc)
  481. {}
  482. const_iterator(const iterator &t) : mOwner(t.mOwner), mLoc(t.mLoc)
  483. {}
  484. // Assignment Operator
  485. //---------------------
  486. void operator= (const const_iterator &t)
  487. {
  488. mOwner = t.mOwner;
  489. mLoc = t.mLoc;
  490. }
  491. // Assignment Operator
  492. //---------------------
  493. void operator= (const iterator &t)
  494. {
  495. mOwner = t.mOwner;
  496. mLoc = t.mLoc;
  497. }
  498. // Equality Operators
  499. //--------------------
  500. bool operator!=(const iterator &t) const
  501. {
  502. return (mLoc!=t.mLoc || mOwner!=t.mOwner);
  503. }
  504. bool operator==(const iterator &t) const
  505. {
  506. return (mLoc==t.mLoc && mOwner==t.mOwner);
  507. }
  508. // Equality Operators
  509. //--------------------
  510. bool operator!=(const const_iterator &t) const
  511. {
  512. return (mLoc!=t.mLoc || mOwner!=t.mOwner);
  513. }
  514. bool operator==(const const_iterator &t) const
  515. {
  516. return (mLoc==t.mLoc && mOwner==t.mOwner);
  517. }
  518. // DeReference Operator
  519. //----------------------
  520. const TTValue& operator* () const
  521. {
  522. assert(mLoc>=0 && mLoc<mOwner->mSize);
  523. return (mOwner->mArray[mLoc]);
  524. }
  525. // DeReference Operator
  526. //----------------------
  527. const TTValue& value() const
  528. {
  529. assert(mLoc>=0 && mLoc<mOwner->mSize);
  530. return (mOwner->mArray[mLoc]);
  531. }
  532. // DeReference Operator
  533. //----------------------
  534. const TTValue* operator-> () const
  535. {
  536. assert(mLoc>=0 && mLoc<mOwner->mSize);
  537. return (&mOwner->mArray[mLoc]);
  538. }
  539. // Inc Operator
  540. //--------------
  541. const_iterator operator++(int)
  542. {
  543. assert(mLoc>=0 && mLoc<mOwner->mSize);
  544. const_iterator old(*this);
  545. mLoc ++;
  546. return old;
  547. }
  548. // Inc Operator
  549. //--------------
  550. const_iterator operator++()
  551. {
  552. assert(mLoc>=0 && mLoc<mOwner->mSize);
  553. mLoc ++;
  554. return *this;
  555. }
  556. };
  557. friend class iterator;
  558. friend class const_iterator;
  559. ////////////////////////////////////////////////////////////////////////////////////
  560. // Iterator Begin (Starts At Address 0)
  561. ////////////////////////////////////////////////////////////////////////////////////
  562. iterator begin()
  563. {
  564. return iterator(this, 0);
  565. }
  566. ////////////////////////////////////////////////////////////////////////////////////
  567. // Iterator End (Set To Address mSize)
  568. ////////////////////////////////////////////////////////////////////////////////////
  569. iterator end()
  570. {
  571. return iterator(this, mSize);
  572. }
  573. ////////////////////////////////////////////////////////////////////////////////////
  574. // Iterator Begin (Starts At Address 0)
  575. ////////////////////////////////////////////////////////////////////////////////////
  576. const_iterator begin() const
  577. {
  578. return const_iterator(this, 0);
  579. }
  580. ////////////////////////////////////////////////////////////////////////////////////
  581. // Iterator End (Set To Address mSize)
  582. ////////////////////////////////////////////////////////////////////////////////////
  583. const_iterator end() const
  584. {
  585. return const_iterator(this, mSize);
  586. }
  587. ////////////////////////////////////////////////////////////////////////////////////
  588. // Iterator Find (If Fails To Find, Returns iterator end()
  589. ////////////////////////////////////////////////////////////////////////////////////
  590. iterator find(const TTValue& value)
  591. {
  592. int index = find_index(value); // Call Find By Index
  593. if (index<mSize)
  594. {
  595. return iterator(this, index); // Found It, Return An Iterator To Index
  596. }
  597. return end(); // Return "end" Iterator If Not Found
  598. }
  599. ////////////////////////////////////////////////////////////////////////////////////
  600. // Iterator Find (If Fails To Find, Returns iterator end()
  601. ////////////////////////////////////////////////////////////////////////////////////
  602. const_iterator find(const TTValue& value) const
  603. {
  604. int index = find_index(value); // Call Find By Index
  605. if (index<mSize)
  606. {
  607. return const_iterator(this, index); // Found It, Return An Iterator To Index
  608. }
  609. return end(); // Return "end" Iterator If Not Found
  610. }
  611. ////////////////////////////////////////////////////////////////////////////////////
  612. // Erase An Iterator Location... NOTE: THIS DOES NOT PRESERVE ORDER IN THE VECTOR!!
  613. ////////////////////////////////////////////////////////////////////////////////////
  614. iterator erase_swap(const iterator &it)
  615. {
  616. assert(it.mLoc>=0 && it.mLoc<it.mOwner->mSize);
  617. if (it.mLoc != mSize - 1)
  618. {
  619. mArray.swap(it.mLoc, mSize - 1);
  620. }
  621. pop_back();
  622. return it;
  623. }
  624. template<class CAST_TO>
  625. CAST_TO *verify_alloc(CAST_TO *p) const
  626. {
  627. return mArray.verify_alloc(p);
  628. }
  629. };
  630. template<class T, int ARG_CAPACITY>
  631. class vector_vs : public vector_base<storage::value_semantics<T,ARG_CAPACITY> >
  632. {
  633. public:
  634. typedef typename storage::value_semantics<T,ARG_CAPACITY> TStorageTraits;
  635. typedef typename TStorageTraits::TValue TTValue;
  636. enum
  637. {
  638. CAPACITY = ARG_CAPACITY
  639. };
  640. vector_vs() {}
  641. };
  642. template<class T, int ARG_CAPACITY>
  643. class vector_os : public vector_base<storage::object_semantics<T,ARG_CAPACITY> >
  644. {
  645. public:
  646. typedef typename storage::object_semantics<T,ARG_CAPACITY> TStorageTraits;
  647. typedef typename TStorageTraits::TValue TTValue;
  648. enum
  649. {
  650. CAPACITY = ARG_CAPACITY
  651. };
  652. vector_os() {}
  653. };
  654. template<class T, int ARG_CAPACITY, int ARG_MAX_CLASS_SIZE>
  655. class vector_is : public vector_base<storage::virtual_semantics<T,ARG_CAPACITY,ARG_MAX_CLASS_SIZE> >
  656. {
  657. public:
  658. typedef typename storage::virtual_semantics<T,ARG_CAPACITY,ARG_MAX_CLASS_SIZE> TStorageTraits;
  659. typedef typename TStorageTraits::TValue TTValue;
  660. enum
  661. {
  662. CAPACITY = ARG_CAPACITY,
  663. MAX_CLASS_SIZE = ARG_MAX_CLASS_SIZE
  664. };
  665. vector_is() {}
  666. };
  667. }
  668. #endif