cvx
Loading...
Searching...
No Matches
random_access_iterator.h
Go to the documentation of this file.
1#include "cvx/fallback.h"
2
3// clang-format off
4#ifndef V
5#error "cvx/iter/random_access_iterator.h requires V to be defined (the element type, e.g. #define V int)"
6#endif
7#ifndef INTERFACE
8#error "cvx/iter/random_access_iterator.h requires INTERFACE to be defined (the struct name, e.g. #define INTERFACE my_iter)"
9#endif
10// clang-format on
11
12#include "cvx/core.h"
13
14struct VTABLE(INTERFACE)
15{
16 // constructors and destructors
17 cvx_container *(*start)(cvx_container *);
19 void (*drop)(cvx_container *);
20 // state
21 bool (*at_start)(cvx_container *);
22 bool (*at_end)(cvx_container *);
23 size_t (*count)(cvx_container *);
24 // movement
25 void (*to_start)(cvx_container *);
26 void (*to_end)(cvx_container *);
27 void (*next)(cvx_container *);
28 void (*prev)(cvx_container *);
29 void (*forward)(cvx_container *, size_t steps);
30 void (*backward)(cvx_container *, size_t steps);
31 void (*go_to)(cvx_container *, size_t index);
32 // access
33 V (*value)(cvx_container *);
34 size_t (*index)(cvx_container *);
35};
36
37struct INTERFACE
38{
39 cvx_container *instance;
40 struct VTABLE(INTERFACE) * vtable;
41};
42
43#undef INTERFACE
Definition deque.h:30
Definition binary_heap.h:135