18.03.2013 - Bug fixes, add in/out speed diagnostic to PIProtocol, fixed PIConsole tab switch segfault, PIObject EVENT / EVENT_HANDLER mechanism update - new EVENT macros that use EVENT_HANDLER with raiseEvent implementation.
This allow compile check event for CONNECT and use EVENT as CONNECT target, also raise event now is simple execute EVENT function.
This commit is contained in:
26
picontainers.h
Executable file → Normal file
26
picontainers.h
Executable file → Normal file
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Generic containers, based on STL
|
||||
Copyright (C) 2012 Ivan Pelipenko peri4ko@gmail.com
|
||||
Copyright (C) 2013 Ivan Pelipenko peri4ko@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -157,7 +157,7 @@ public:
|
||||
PIFlags operator ^(PIFlags f) const {PIFlags tf(flags ^ f.flags); return tf;}
|
||||
PIFlags operator ^(Enum e) const {PIFlags tf(flags ^ e); return tf;}
|
||||
PIFlags operator ^(int i) const {PIFlags tf(flags ^ i); return tf;}
|
||||
bool operator [](Enum e) {return (flags & e) == e;}
|
||||
bool operator [](Enum e) const {return (flags & e) == e;}
|
||||
operator int() const {return flags;}
|
||||
private:
|
||||
int flags;
|
||||
@@ -394,12 +394,15 @@ public:
|
||||
_CVector & fill(const Type & t) {_stlc::assign(_stlc::size(), t); return *this;}
|
||||
_CVector & pop_front() {_stlc::erase(_stlc::begin()); return *this;}
|
||||
_CVector & push_front(const Type & t) {_stlc::insert(_stlc::begin(), t); return *this;}
|
||||
Type take_front() {Type t(_stlc::front()); pop_front(); return t;}
|
||||
Type take_back() {Type t(_stlc::back()); _stlc::pop_back(); return t;}
|
||||
_CVector & remove(uint num) {_stlc::erase(_stlc::begin() + num); return *this;}
|
||||
_CVector & remove(uint num, uint count) {_stlc::erase(_stlc::begin() + num, _stlc::begin() + num + count); return *this;}
|
||||
//_CVector & remove(const Type & t) {for (typename _stlc::iterator i = _stlc::begin(); i != _stlc::end(); ++i) if (t == *i) {_stlc::erase(i); --i;} return *this;}
|
||||
_CVector & removeOne(const Type & v) {for (typename _stlc::iterator i = _stlc::begin(); i != _stlc::end(); ++i) if (v == *i) {_stlc::erase(i); return *this;} return *this;}
|
||||
_CVector & removeAll(const Type & v) {for (typename _stlc::iterator i = _stlc::begin(); i != _stlc::end(); ++i) if (v == *i) {_stlc::erase(i); --i;} return *this;}
|
||||
_CVector & insert(uint pos, const Type & t) {_stlc::insert(_stlc::begin() + pos, t); return *this;}
|
||||
_CVector & insert(uint pos, const _CVector & t) {_stlc::insert(_stlc::begin() + pos, t.begin(), t.end()); return *this;}
|
||||
_CVector & operator <<(const Type & t) {_stlc::push_back(t); return *this;}
|
||||
_CVector & operator <<(const _CVector & t) {for (typename _stlc::const_iterator i = t.begin(); i != t.end(); i++) _stlc::push_back(*i); return *this;}
|
||||
bool operator ==(const _CVector & t) {for (uint i = 0; i < _stlc::size(); ++i) if (t[i] != at(i)) return false; return true;}
|
||||
@@ -518,16 +521,19 @@ template<typename Type0, typename Type1>
|
||||
inline bool operator <(const PIPair<Type0, Type1> & value0, const PIPair<Type0, Type1> & value1) {return value0.first < value1.first;}
|
||||
|
||||
|
||||
template<typename Type, typename Key = int>
|
||||
class PIMap: public PISet<PIPair<Key, Type> > {
|
||||
typedef PIMap<Type, Key> _CMap;
|
||||
typedef PISet<PIPair<Key, Type> > _CSet;
|
||||
template<typename Key, typename Type>
|
||||
class PIMap: public map<Key, Type> {
|
||||
typedef PIMap<Key, Type> _CMap;
|
||||
typedef map<Key, Type> _stlc;
|
||||
typedef std::pair<Key, Type> _stlpair;
|
||||
public:
|
||||
PIMap() {;}
|
||||
PIMap(const Type & value, const Key & key) {insert(value, key);}
|
||||
_CMap & insert(const Type & value, const Key & key) {_CSet::insert(PIPair<Key, Type>(key, value)); return *this;}
|
||||
Type value(Key key) const {for (typename _CMap::iterator i = _CMap::begin(); i != _CMap::end(); i++) if ((*i).first == key) return (*i).second; return Type();}
|
||||
Type operator[](Key key) const {return value(key);}
|
||||
PIMap(const Key & key_, const Type & value_) {insert(key_, value_);}
|
||||
_CMap & insert(const Key & key_, const Type & value_) {_stlc::insert(std::pair<Key, Type>(key_, value_)); return *this;}
|
||||
_CMap & insert(PIPair<Key, Type> entry_) {_stlc::insert(std::pair<Key, Type>(entry_.first, entry_.second)); return *this;}
|
||||
Key key(Type value_) const {for (typename _stlc::const_iterator i = _stlc::begin(); i != _stlc::end(); i++) if (i->second == value_) return i->first; return Key();}
|
||||
Type & value(Key key_) {return (*this)[key_];}
|
||||
Type value(Key key_) const {return (*this)[key_];}
|
||||
};
|
||||
|
||||
#endif // PICONTAINERS_H
|
||||
|
||||
Reference in New Issue
Block a user