libUTL++
TDeque.h
1 #pragma once
2 
4 
5 #include <libutl/TDequeIt.h>
6 
8 
9 UTL_NS_BEGIN;
10 
12 
22 
24 template <class T>
25 class TDeque : public Deque
26 {
29 
30 public:
31  TDeque(bool owner, Ordering* ordering = nullptr)
32  : Deque(owner, ordering)
33  {
34  }
35 
36  T*
37  front() const
38  {
39  return utl::cast<T>(Deque::front());
40  }
41 
42  T*
43  back() const
44  {
45  return utl::cast<T>(Deque::back());
46  }
47 
48  T*
49  get(size_t idx) const
50  {
51  return utl::cast<T>(Deque::get(idx));
52  }
53 
55  T*
56  findT(const Object& key) const
57  {
58  return utl::cast<T>(Deque::find(key));
59  }
60 
62  findIt(const Object& key) const
63  {
64  TDequeIt<T> res;
65  res.copy(Deque::findIt(key));
66  return res;
67  }
68 
70  findIt(const Object& key)
71  {
72  TDequeIt<T> res;
73  res.copy(Deque::findIt(key));
74  return res;
75  }
76 
77  bool
78  add(const T& object)
79  {
80  return super::add(const_cast<T&>(object));
81  }
82 
83  bool
84  add(const T* object)
85  {
86  return super::add(const_cast<T*>(object));
87  }
88 
89  void
90  add(const Collection& collection)
91  {
92  super::add(collection);
93  }
94 
96  begin() const
97  {
98  TDequeIt<T> res;
99  res.copy(Deque::begin());
100  return res;
101  }
102 
104  begin()
105  {
106  TDequeIt<T> res;
107  res.copy(Deque::begin());
108  return res;
109  }
110 
112  end() const
113  {
114  TDequeIt<T> res;
115  res.copy(Deque::end());
116  return res;
117  }
118 
120  end()
121  {
122  TDequeIt<T> res;
123  res.copy(Deque::end());
124  return res;
125  }
126 
127 public:
128  typedef T type;
129  typedef TDequeIt<T> iterator;
130  typedef T* value_type; // for STL
131 };
132 
134 
135 UTL_NS_END;
136 
138 
#define UTL_CLASS_IMPL_TPL(className, T)
Implementation of standard UTL++ functionality for a template class.
Definition: macros.h:906
#define UTL_CLASS_DEFID
Default init() and deInit() (which are merely place-holders).
Definition: macros.h:532
Object comparison abstraction.
Definition: Ordering.h:30
Template version of DequeIt.
Definition: TDequeIt.h:23
Templated proxy for BidIt.
Definition: TBidIt.h:19
T * findT(const Object &key) const
See find().
Definition: TDeque.h:56
Template version of Deque.
Definition: TDeque.h:25
virtual void copy(const Object &rhs)
Copy another DequeIt.
#define UTL_CLASS_DECL_TPL(DC, T, BC)
Declaration of standard UTL++ functionality for a template class with one parameter.
Definition: macros.h:713
A sequence of objects permitting efficient insertion and removal at either end.
Definition: Deque.h:28
Root of UTL++ class hierarchy.
Definition: Object.h:52
A collection of objects.
Definition: Collection.h:62