01.03.2011 - as a initial commit
This commit is contained in:
29
piincludes.h
29
piincludes.h
@@ -10,8 +10,16 @@
|
||||
|
||||
#include <iostream>
|
||||
#include <unistd.h>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#ifndef QNX
|
||||
# include <cstdio>
|
||||
# include <cstdlib>
|
||||
#else
|
||||
# include <stdio.h>
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -51,6 +59,7 @@ public:
|
||||
inline Type & at(uint index) {return (*this)[index];}
|
||||
inline const Type * data(uint index = 0) const {return &(*this)[index];}
|
||||
inline Type * data(uint index = 0) {return &(*this)[index];}
|
||||
inline void fill(const Type & t) {vector<Type, Allocator>::assign(vector<Type, Allocator>::size(), t);}
|
||||
inline void pop_front() {vector<Type, Allocator>::erase(vector<Type, Allocator>::begin());}
|
||||
inline void push_front(const Type & t) {vector<Type, Allocator>::insert(vector<Type, Allocator>::begin(), t);}
|
||||
inline void remove(uint num) {vector<Type, Allocator>::erase(vector<Type, Allocator>::begin() + num);}
|
||||
@@ -58,6 +67,17 @@ public:
|
||||
inline void insert(uint pos, const Type & t) {vector<Type, Allocator>::insert(vector<Type, Allocator>::begin() + pos, t);}
|
||||
};
|
||||
|
||||
template<typename Type, typename Allocator = std::allocator<Type> >
|
||||
class PIList: public list<Type, Allocator> {
|
||||
public:
|
||||
inline const Type * data(uint index = 0) const {return &(*this)[index];}
|
||||
inline Type * data(uint index = 0) {return &(*this)[index];}
|
||||
inline void fill(const Type & t) {list<Type, Allocator>::assign(list<Type, Allocator>::size(), t);}
|
||||
inline void remove(uint num) {list<Type, Allocator>::erase(list<Type, Allocator>::begin() + num);}
|
||||
inline void remove(uint num, uint count) {list<Type, Allocator>::erase(list<Type, Allocator>::begin() + num, list<Type, Allocator>::begin() + num + count);}
|
||||
inline void insert(uint pos, const Type & t) {list<Type, Allocator>::insert(list<Type, Allocator>::begin() + pos, t);}
|
||||
};
|
||||
|
||||
template<typename Enum>
|
||||
class Flags {
|
||||
private:
|
||||
@@ -88,6 +108,11 @@ public:
|
||||
inline int random() {return rand();}
|
||||
#endif
|
||||
|
||||
template<typename Type> inline void piSwap(Type & f, Type & s) {Type t = f; f = s; s = t;}
|
||||
template<typename Type> inline Type piMin(const Type & f, const Type & s) {return (f > s) ? s : f;}
|
||||
template<typename Type> inline Type piMax(const Type & f, const Type & s) {return (f < s) ? s : f;}
|
||||
template<typename Type> inline Type piMin(const Type & f, const Type & s, const Type & t) {return (f < s && f < t) ? f : ((s < t) ? s : t);}
|
||||
template<typename Type> inline Type piMax(const Type & f, const Type & s, const Type & t) {return (f > s && f > t) ? f : ((s > t) ? s : t);}
|
||||
inline bool atob(const string & str) { return str == "1" ? true : false;};
|
||||
inline string btos(const bool num) { return num ? "0" : "1";};
|
||||
inline string itos(const int num) {
|
||||
|
||||
Reference in New Issue
Block a user