16.01.2011 - new modules - pimath and pigeometry

This commit is contained in:
peri4
2011-01-18 13:15:41 +03:00
parent a32edb1fef
commit 3610ea9212
17 changed files with 817 additions and 63 deletions

View File

@@ -44,6 +44,20 @@ using std::list;
using std::deque;
using std::string;
template<typename Type, typename Allocator = std::allocator<Type> >
class PIVector: public vector<Type, Allocator> {
public:
inline const Type & at(uint index) const {return (*this)[index];}
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 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);}
inline void remove(uint num, uint count) {vector<Type, Allocator>::erase(vector<Type, Allocator>::begin() + num, vector<Type, Allocator>::begin() + num + count);}
inline void insert(uint pos, const Type & t) {vector<Type, Allocator>::insert(vector<Type, Allocator>::begin() + pos, t);}
};
template<typename Enum>
class Flags {
private:
@@ -70,6 +84,9 @@ public:
inline operator int() const {return flags;}
};
#ifdef WINDOWS
inline int random() {return rand();}
#endif
inline bool atob(const string & str) { return str == "1" ? true : false;};
inline string btos(const bool num) { return num ? "0" : "1";};