1 // ANNA - Anna is Not Nothingness Anymore //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo //
5 // See project site at http://redmine.teslayout.com/projects/anna-suite //
6 // See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
13 #include <anna/core/core.hpp>
18 static int value (int* i) throw () { return *i; }
19 static int value (const int* i) throw () { return *i; }
23 throw (RuntimeException)
27 49800, 49801, 49802, 57000, 49804, 49805, 49806, 62000, 102400, 49806, 62001, 49808,
28 102401, 67400, 49809, 71100, 49700, 63900, 49810, 67420, 67300, -1
31 SortedVector <int, Accesor> sorted;
32 typedef SortedVector <int, Accesor>::iterator iterator;
34 for (int i = 0; values [i] != -1; i ++)
35 sorted.add (&values [i]);
37 for (iterator ii = sorted.begin (), maxii = sorted.end (); ii != maxii; ii ++)
38 cout << functions::asString (Accesor::value (SortedVector <int, Accesor>::data (ii))) << " ";
45 for (int i = 0; values [i] != -1; i ++) {
46 value = values [i] - 1;
47 found = sorted.contains (&value);
48 msg = functions::asText ("Number-: ", value);
49 msg += functions::asText (" | Exists: ", found);
50 Logger::debug (msg, ANNA_FILE_LOCATION);
52 found = sorted.contains (&values [i]);
53 msg = functions::asText ("Key: ", values [i]);
54 msg += functions::asText (" | Exists: ", found);
55 Logger::debug (msg, ANNA_FILE_LOCATION);
57 value = values [i] + 1;
58 found = sorted.contains (&value);
59 msg = functions::asText ("Number+: ", value);
60 msg += functions::asText (" | Exists: ", found);
61 Logger::debug (msg, ANNA_FILE_LOCATION);
64 for (int loop = 0; loop < 500; loop ++) {
65 for (int i = 0; values [i] != -1; i ++) {
66 value = values [i] - 1;
67 found = sorted.contains (&value);
69 found = sorted.contains (&values [i]);
71 value = values [i] + 1;
72 found = sorted.contains (&value);
77 int main (int argc, const char** argv)
80 Logger::setLevel (Logger::Debug);
81 Logger::initialize ("testfunctions", new TraceWriter ("file.trace", 2048000));
85 catch (Exception& ex) {
86 cout << ex.asString () << endl;