mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 14:16:07 -06:00
New Core Tutorial
git-svn-id: svn://ultimatepp.org/upp/trunk@10538 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
dd88feaf2e
commit
6c22e727de
37 changed files with 3125 additions and 0 deletions
28
tutorial/CoreTutorial/InVector.cpp
Normal file
28
tutorial/CoreTutorial/InVector.cpp
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
#include "Tutorial.h"
|
||||
|
||||
void InVectorTutorial()
|
||||
{
|
||||
/// .`InVector`, `InArray`
|
||||
|
||||
/// `InVector` and `InArray` are container types quite similar to `Vector`/`Array`, but
|
||||
/// they trade the speed of `operator[]` with the ability to insert or remove elements at
|
||||
/// any position quickly. You can expect `operator[]` to be about 10 times slower than in
|
||||
/// Vector (but that is still quite fast), while `Insert` at any position scales well up to
|
||||
/// hundreds of megabytes of data (e.g. `InVector` containing 100M of String elements is
|
||||
/// handled without problems).
|
||||
|
||||
InVector<int> v;
|
||||
for(int i = 0; i < 1000000; i++)
|
||||
v.Add(i);
|
||||
v.Insert(0, -1); // This is fast
|
||||
|
||||
/// While the interface of `InVector`/`InArray` is almost identical to `Vector`/`Array`,
|
||||
/// `InVector`/`InArray` in addition implements `FindLowerBound`/`FindUpperBound` methods -
|
||||
/// while normal generic range algorithms work, it is possible to provide
|
||||
/// `InVector`/`InArray` specific optimizations that basically match the performace of
|
||||
/// `Find*Bound` on simple `Vector`.
|
||||
|
||||
DUMP(v.FindLowerBound(55));
|
||||
|
||||
///
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue