46# define RAND( x ) (unsigned long) ( x * ( rand() / (RAND_MAX+1.0) ) )
61int main(
int argc,
char *argv[])
63 unsigned long seed,index;
64 unsigned long i,
value, val;
66 unsigned long NUM_ITE = 1000;
69 char * endptr =
nullptr;
71 const unsigned long parsed = strtoul(argv[1], &endptr, 10);
72 if (errno != 0 or endptr == argv[1] or *endptr !=
'\0'
73 or parsed >
static_cast<unsigned long>(INT_MAX))
75 cerr <<
"Invalid iteration count: " << argv[1] << endl;
84 seed = std::time(
nullptr);
93 cout << t[10]->a1 << t[10000]->a1 << endl;
95 cout <<
"./testDynArray " << NUM_ITE <<
" " <<
seed << endl;
102 for(i = 0; i < NUM_ITE; i++)
105 index =
RAND(NUM_ITE);
107 v2[index] = v1[index];
110 cout <<
"(" << val <<
") (" <<
value <<
") ";
111 assert(v2[index] == v1[index]);
133 catch(
const std::overflow_error&)
135 cout <<
"Overflow!" << endl;
137 catch(
const std::bad_alloc&)
139 cout <<
"Not enough memory!" << endl;
141 catch(
const std::invalid_argument&)
143 cout <<
"invalid_argument!" << endl;
145 catch (
const std::exception & e)
147 cout << e.what() << endl;
156 cout << s.
access(0) <<
" ****************" << endl;
158 cout << s.
access(0) <<
" ****************" << endl;
162 cout << s[1] <<
" ****************" << endl;
171 cout << s[0] <<
" ****************" << endl;
173 cout << s.
access(0) <<
" ****************" << endl;
177 cout << s[1] <<
" ****************" << endl;
182 for (
size_t i = 0; i < NUM_ITE; ++i)
186 cout << it.get_curr() <<
" ";
size_t size_t int32_t value
Iterator on the items of array.
void reset_last() noexcept
Reset the iterator to the last item.
void prev()
Move the current a position backward.
bool has_curr() const noexcept
Check whether the iterator refers to an item.
T & get_curr() const
Return the current item.
Set-like container backed by a dynamic array.
void swap(DynArray< T > &array) noexcept(std::is_nothrow_swappable_v< T >)
Swap in constant time array with this
T & touch(const size_t i)
Touch the entry i.
T & access(const size_t i) noexcept
Fast access without checking allocation and bound_min_clock checking.
T & append()
Allocate a new entry to the end of array.
void reserve(const size_t l, const size_t r)
Allocate a range of entries.
Main namespace for Aleph-w library functions.