source: doc/theses/mike_brooks_MMath/benchmarks/list/fx-cpp-stlref.h @ 719fdbc

Last change on this file since 719fdbc was 0b66ef9, checked in by Michael Brooks <mlbrooks@…>, 20 months ago

Add linked list performance experiment

  • Property mode set to 100644
File size: 1.2 KB
Line 
1#include <list>
2using namespace std;
3
4#define BFX_INTRUSION(S)
5#define BFX_EXTRUSION_DECL(S)
6#define BFX_EXTRUSION_FOLLOWUP(S)
7#define BFX_LIST_HEAD_T(S)                       list<S*>
8#define BFX_LISTED_ELEM_T(S)                     list<S*>::iterator
9
10#define BFX_INSERT_FIRST(S, lst, item)           (lst.push_front(&item), lst.begin())
11#define BFX_INSERT_LAST(S, lst, item)            (lst.push_back(&item), BFX_GET_BEFORE(S, lst, lst.end()))
12#define BFX_REMOVE_FIRST(S, lst)                 lst.pop_front()
13#define BFX_REMOVE_LAST(S, lst)                  lst.pop_back()
14#define BFX_INSERT_BEFORE(S, lst, item, refIter) lst.insert(refIter, &item)
15#define BFX_INSERT_AFTER(S, lst, item, refIter)  lst.insert(BFX_GET_AFTER(S, lst, refIter), &item)
16#define BFX_REMOVE_HERE(S, lst, refIter)         lst.erase(refIter)
17#define BFX_INIT(S, lst)
18
19#define BFX_GET_AFTER(S, lst, iter)              ({ list<S*>::iterator answer = (iter); answer++; answer;})
20#define BFX_GET_BEFORE(S, lst, iter)             ({ list<S*>::iterator answer = (iter); if ((answer) == lst.begin()) { answer = lst.end(); } else { answer--; } answer; })
21#define BFX_IS_VALID_POS(S, lst, iter)           ((iter)!=lst.end())
22#define BFX_DEREF_POS(S, lst, iter)              (*iter)
Note: See TracBrowser for help on using the repository browser.