PIP  1.7.1
Platform-Independent Primitives
picontainers.h File Reference

Base for generic containers. More...

Macros

#define piForeach(i, c)
 Macro for iterate any container. More...
 
#define piForeachC(i, c)
 Macro for iterate any container only for read. More...
 
#define piForeachR(i, c)
 Macro for iterate any container with reverse direction. More...
 
#define piForeachCR(i, c)
 Macro for iterate any container only for read with reverse direction. More...
 
#define piBreak
 Macro for break from any piForeach* loop. More...
 

Detailed Description

Base for generic containers.

This file declare all containers and useful macros to use them

Macro Definition Documentation

◆ piForeach

#define piForeach (   i,
 
)

Macro for iterate any container.

Use this macros instead of standard "for" to get read/write access to each element of container. Pass direction is direct
Example:

vec << 1 << 2 << 3;
piForeach (int & i, vec)
cout << i << ", ";
// 1, 2, 3,
piForeach (int & i, vec)
i++;
piForeach (int & i, vec)
cout << i << ", ";
// 2, 3, 4,

◆ piForeachC

#define piForeachC (   i,
 
)

Macro for iterate any container only for read.

Use this macros instead of standard "for" to get read access to each element of container. Pass direction is direct
Example:

vec << 1 << 2 << 3;
piForeachC (int & i, vec)
cout << i << ", ";
// 1, 2, 3,
piForeachC (int & i, vec)
i++; // ERROR! const iterator

◆ piForeachR

#define piForeachR (   i,
 
)

Macro for iterate any container with reverse direction.

Use this macros instead of standard "for" to get read/write access to each element of container. Pass direction is reverse
Example:

vec << 1 << 2 << 3;
piForeachR (int & i, vec)
cout << i << ", ";
// 3, 2, 1,
piForeachR (int & i, vec)
i++;
piForeachR (int & i, vec)
cout << i << ", ";
// 4, 3, 2,

◆ piForeachCR

#define piForeachCR (   i,
 
)

Macro for iterate any container only for read with reverse direction.

Use this macros instead of standard "for" to get read access to each element of container. Pass direction is reverse
Example:

vec << 1 << 2 << 3;
piForeachCR (int & i, vec)
cout << i << ", ";
// 3, 2, 1,
piForeachCR (int & i, vec)
i++; // ERROR! const iterator

◆ piBreak

#define piBreak

Macro for break from any piForeach* loop.

Warning
C++ ordinary "break" doesn`t work inside piForeach* loops! Always use "piBreak" instead!