36#include "DGtal/base/Common.h"
37#include "DGtal/base/IndexedListWithBlocks.h"
38#include "DGtal/base/Labels.h"
43template <
typename Container1,
typename Container2>
45isEqual( Container1 & c1, Container2 & c2 )
47 return ( c1.size() == c2.size() )
48 && std::equal( c1.begin(), c1.end(), c2.begin() );
51template <
typename VContainer1,
typename LContainer2>
52void insert( VContainer1 & c1, LContainer2 & c2,
unsigned int idx,
double v )
54 c1.insert( c1.begin() + idx, v );
58template <
typename VContainer1,
typename LContainer2>
63 for (
unsigned int i = 0; i < nb; ++i )
65 unsigned int idx = rand() % ( l.size() + 1 );
66 double val = ( (double)rand() ) / RAND_MAX;
72template <
typename VContainer1,
typename LContainer2>
73void erase( VContainer1 & c1, LContainer2 & c2,
unsigned int idx )
75 c1.erase( c1.begin() + idx );
79template <
typename VContainer1,
typename LContainer2>
84 for (
unsigned int i = 0; i < nb; ++i )
86 unsigned int idx = rand() % ( l.size() );
100 unsigned int nbok = 0;
104 ++nb; nbok +=
isEqual( v, l ) ? 1 : 0;
105 std::cout <<
"(" << nbok <<
"/" << nb <<
") l=" << l << std::endl;
107 ++nb; nbok +=
isEqual( v, l ) ? 1 : 0;
108 std::cout <<
"(" << nbok <<
"/" << nb <<
") l=" << l << std::endl;
110 ++nb; nbok +=
isEqual( v, l ) ? 1 : 0;
111 std::cout <<
"(" << nbok <<
"/" << nb <<
") l=" << l << std::endl;
113 ++nb; nbok +=
isEqual( v, l ) ? 1 : 0;
114 std::cout <<
"(" << nbok <<
"/" << nb <<
") l=" << l << std::endl;
117 ++nb; nbok +=
isEqual( v, l ) ? 1 : 0;
118 std::cout <<
"(" << nbok <<
"/" << nb <<
") l=" << l << std::endl;
120 ++nb; nbok +=
isEqual( v, l ) ? 1 : 0;
121 std::cout <<
"(" << nbok <<
"/" << nb <<
") l=" << l << std::endl;
122 insert( v, l, (
unsigned int)v.size(), -13.1 );
123 ++nb; nbok +=
isEqual( v, l ) ? 1 : 0;
124 std::cout <<
"(" << nbok <<
"/" << nb <<
") l=" << l << std::endl;
126 std::cout <<
"(" << nbok <<
"/" << nb <<
") 10000 insertions" << std::endl;
127 ++nb; nbok +=
checkErase( v, l, 10000 ) ? 1 : 0;
128 std::cout <<
"(" << nbok <<
"/" << nb <<
") 10000 deletions l=" << l << std::endl;
130 return ( nb == nbok ) ? 0 : 1;
Aim: Represents a mixed list/array structure which is useful in some context. It is essentially a lis...
void beginBlock(const std::string &keyword="")
DGtal is the top-level namespace which contains all DGtal functions and types.
Go to http://www.sgi.com/tech/stl/Container.html.
Go to http://www.sgi.com/tech/stl/ForwardIterator.html.
void erase(VContainer1 &c1, LContainer2 &c2, unsigned int idx)
bool isEqual(Container1 &c1, Container2 &c2)
bool checkInsert(VContainer1 &v, LContainer2 &l, unsigned int nb)
void insert(VContainer1 &c1, LContainer2 &c2, unsigned int idx, double v)
bool checkErase(VContainer1 &v, LContainer2 &l, unsigned int nb)