32#include "DGtal/base/Common.h"
34#include "DGtal/kernel/SpaceND.h"
35#include "DGtal/kernel/domains/HyperRectDomain.h"
36#include "DGtal/images/ImageContainerByHashTree.h"
40#define dim experimental::ImageContainerByHashTree<Domain , T, DGtal::uint64_t >::dim
41#define defHashKey typename experimental::ImageContainerByHashTree<Domain , int, DGtal::uint64_t >::HashKey
47 double f = ( double ) rand() / RAND_MAX;
48 return (
int) (iMin +
static_cast<double> ( f * ( iMax - iMin ) ));
51template<
typename Domain,
typename T >
54 srand ( (
unsigned int)time ( NULL ) );
60 unsigned DepthMask = 100000;
62 for (
int key = DepthMask; key > 1; --key )
70 if ( checkAfterEachSet )
74 trace.
info() <<
"test_set: failure in phase 1" << std::endl
82 trace.
info() <<
"checking the container's validity..." << std::endl;
86 trace.
info() <<
"test_set: failure in phase 1" << std::endl;
92 for (
unsigned key = container.ROOT_KEY; key < DepthMask; ++key )
99 if ( checkAfterEachSet )
102 trace.
info() <<
"test_set: failure in phase 2" << std::endl
110 trace.
info() <<
"test_set: failure in phase 2" << std::endl;
114 trace.
info() <<
"test_set: success !" << std::endl;
119template<
typename Domain,
typename T >
122 srand ( (
unsigned int)time ( NULL ) );
125 unsigned DepthMask = 100000;
127 for (
unsigned key = DepthMask; key > container.ROOT_KEY; --key )
135 T val =
iRand ( 0, 100 );
145 if ( val != container.
get ( key2 ) )
147 trace.
info() <<
"test_get: failure" << std::endl
155 trace.
info() <<
"test_get: success !" << std::endl
156 <<
"tested with " << count <<
" keys" << std::endl;
162int main (
int argc,
char** argv )
166 for (
int i = 0; i < argc; ++i )
173 Tree tree ( 12,5,1 );
178 Dom::Point p1, p2, p3;
179 trace.
info() <<
"azertyuiop" << std::endl;
197 trace.
info() <<
"azertyuiop" << std::endl;
199 trace.
info() <<
"azertyuiop" << std::endl;
200 trace.
info() <<
"coord get " << tree2.
get ( p1 ) << std::endl;
201 trace.
info() <<
"_-_-_-_-_-_-_-_-_-_-_-_-" << std::endl;
202 trace.
info() <<
"coord get " << tree2.
get ( p3 ) << std::endl;
203 trace.
info() <<
"coord get " << tree2.
get ( p1+=p3 ) << std::endl;
204 trace.
info() <<
"coord get " << tree2.
get ( p1+=p3 ) << std::endl;
205 trace.
info() <<
"coord get " << tree2.
get ( p1+=p3 ) << std::endl;
206 trace.
info() <<
"coord get " << tree2.
get ( p1+=p3 ) << std::endl;
210 HashTreeIterator it = tree.begin();
211 for ( it = tree.begin(); it != tree.end(); ++it )
224 trace.
emphase() << ( res ?
"Passed." :
"Error." ) << std::endl;
Aim: Parallelepidec region of a digital space, model of a 'CDomain'.
void beginBlock(const std::string &keyword="")
Built-in iterator on an HashTree. This iterator visits all node in the tree.
Model of CImageContainer implementing the association key<->Value using a hash tree....
bool checkIntegrity(HashKey key=ROOT_KEY, bool leafAbove=false) const
Value get(const HashKey key) const
bool isKeyValid(HashKey key) const
void setValue(const HashKey key, const Value object)
DGtal is the top-level namespace which contains all DGtal functions and types.
static std::string bitString(T value, unsigned nbBits=0)
Bits Structs grouping all the functions of this tiny library for bitwise calculation.
bool test_setVal(experimental::ImageContainerByHashTree< Domain, T, DGtal::uint64_t > &container, bool checkAfterEachSet)
int iRand(int iMin, int iMax)
bool test_get(experimental::ImageContainerByHashTree< Domain, T, DGtal::uint64_t > &container, bool)