Initial community commit
This commit is contained in:
parent
537bcbc862
commit
fc06254474
16440 changed files with 4239995 additions and 2 deletions
55
Src/Wasabi/bfc/foreach.h
Normal file
55
Src/Wasabi/bfc/foreach.h
Normal file
|
@ -0,0 +1,55 @@
|
|||
#ifndef _FOREACH_H
|
||||
#define _FOREACH_H
|
||||
|
||||
#include "memblock.h"
|
||||
#include "ptrlist.h"
|
||||
|
||||
|
||||
// foreach stuff
|
||||
/* use like this:
|
||||
PtrList<blah> list;
|
||||
foreach(list)
|
||||
list.getfor()->booga();
|
||||
something(list.getfor());
|
||||
endfor
|
||||
*/
|
||||
|
||||
// foreach stuff
|
||||
class __foreach
|
||||
{
|
||||
public:
|
||||
__foreach(const PtrListRoot &ptrlist, int reverse=FALSE);
|
||||
__foreach(const PtrListRoot *ptrlist, int reverse=FALSE);
|
||||
|
||||
int done() const;
|
||||
void *next(int advance = TRUE);
|
||||
void *getPtr() const;
|
||||
|
||||
int getPos() const;
|
||||
|
||||
private:
|
||||
MemBlock<void *> list;
|
||||
int pos;
|
||||
};
|
||||
|
||||
#define foreach(x) \
|
||||
{ \
|
||||
void *__fe_void; \
|
||||
__foreach ___f(x); \
|
||||
for (__fe_void = ___f.getPtr(); !___f.done(); __fe_void = ___f.next()) {
|
||||
#define getfor() castFor(__fe_void)
|
||||
#define endfor \
|
||||
} \
|
||||
}
|
||||
#define foreach_reverse(x) \
|
||||
{ \
|
||||
void *__fe_void; \
|
||||
__foreach ___f(x, TRUE); \
|
||||
for (__fe_void = ___f.getPtr(); !___f.done(); __fe_void = ___f.next()) {
|
||||
#define getfor() castFor(__fe_void)
|
||||
#define endfor \
|
||||
} \
|
||||
}
|
||||
#define foreach_index (___f.getPos())
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue