UNIVERS  15.3
UNIVERS base processing software API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
zqb_objectarray.hpp
1 /* zqb_objectarray.hpp */
2 /* $Id: zqb_objectarray.hpp,v 1.2 2006/06/13 10:18:42 guser4 Exp $ */
3 #ifndef __zqb_objectarray_hpp
4 #define __zqb_objectarray_hpp
5 
6 #include <stdio.h>
7 
8 #include <vector>
9 
10 
12 class ZqObject;
13 
14 
16 typedef std::vector<ZqObject*> ZqObjectVector;
17 
26 class ZqbObjectArray : public ZqObjectVector
27 {
28 public:
29 
31  int count () const {
32  return size();
33  }
34 
35  /*
36  * Associative operations
37  */
38 
41  ZqObjectVector::iterator find (ZqObject* pObj) {
42  ZqObjectVector::iterator ppObj;
43  for(ppObj = begin(); ppObj != end(); ++ppObj) {
44  if(*ppObj == pObj)
45  return ppObj;
46  }
47  return end();
48  }
49 
53  bool put (ZqObject* pObj) {
54  ZqObjectVector::iterator ppObj = find(pObj);
55  if(end() != ppObj)
56  return false;
57  push_back(pObj);
58  return true;
59  }
60 
64  bool remove (ZqObject* pObj) {
65  ZqObjectVector::iterator ppObj = find(pObj);
66  if(end() == ppObj)
67  return false;
68  erase(ppObj);
69  return true;
70  }
71 
72 
76  bool toEnd (ZqObject* pObj) {
77  ZqObjectVector::iterator ppObj = find(pObj);
78  if(end() == ppObj)
79  return false;
80  erase(ppObj);
81  push_back(pObj);
82  return true;
83  }
84 
85 
89  bool toBegin (ZqObject* pObj) {
90  ZqObjectVector::iterator ppObj = find(pObj);
91  if(end() == ppObj)
92  return false;
93  erase(ppObj);
94  insert(begin(), pObj);
95  return true;
96  }
97 
100 };
101 
102 
103 #endif /* zqb_objectarray.hpp */
int count() const
Definition: zqb_objectarray.hpp:31
ZqObjectVector::iterator find(ZqObject *pObj)
Definition: zqb_objectarray.hpp:41
Definition: zqb_objectarray.hpp:26
Definition: zq_object.hpp:36
bool toBegin(ZqObject *pObj)
Definition: zqb_objectarray.hpp:89
bool toEnd(ZqObject *pObj)
Definition: zqb_objectarray.hpp:76
bool put(ZqObject *pObj)
Definition: zqb_objectarray.hpp:53