1 #ifndef ROSE_WorkLists_H
2 #define ROSE_WorkLists_H
4 #include <boost/logic/tribool.hpp>
57 template<
typename T,
class Compare = std::less<T> >
81 bool unshift(
const T&, boost::tribool check_uniqueness=boost::indeterminate);
86 template<
class Iterator>
87 size_t unshift(
const Iterator &begin,
const Iterator &end, boost::tribool check_uniqueness=boost::indeterminate);
94 bool push(
const T&, boost::tribool check_uniqueness=boost::indeterminate);
99 template<
class Iterator>
100 size_t push(
const Iterator &begin,
const Iterator &end, boost::tribool check_uniqueness=boost::indeterminate);
109 const T&
front()
const;
110 const T&
back()
const;
124 void add(
const std::vector<T> &items) {
push(items.begin(), items.end()); }
125 void add(
const std::set<T> &items) {
push(items.begin(), items.end()); }
146 template<typename T, class Compare = std::less<T> >
156 template<
typename T,
class Compare = std::less<T> >
166 template<
typename T,
class Compare>
170 if (indeterminate(check_uniqueness))
173 std::pair<typename std::map<T, size_t, Compare>::iterator,
bool> found =
map_.insert(std::pair<T, size_t>(item, 1));
174 if (check_uniqueness && !found.second)
177 ++found.first->second;
178 }
else if (check_uniqueness) {
182 list_.push_front(item);
187 template<
typename T,
class Compare>
188 template<
class Iterator>
193 for (Iterator i=begin; i!=end; ++i) {
194 if (
unshift(*i, check_uniqueness))
200 template<
typename T,
class Compare>
204 if (indeterminate(check_uniqueness))
207 std::pair<typename std::map<T, size_t, Compare>::iterator,
bool> found =
map_.insert(std::make_pair(item, 1));
208 if (check_uniqueness && !found.second)
211 ++found.first->second;
212 }
else if (check_uniqueness) {
216 list_.push_back(item);
221 template<
typename T,
class Compare>
222 template<
class Iterator>
227 for (Iterator i=begin; i!=end; ++i) {
228 if (
push(*i, check_uniqueness))
234 template<
typename T,
class Compare>
239 T item =
list_.front();
245 template<
typename T,
class Compare>
250 T item =
list_.back();
256 template<
typename T,
class Compare>
261 return list_.front();
264 template<
typename T,
class Compare>
272 template<
typename T,
class Compare>
277 typename std::map<T, size_t>::iterator found =
map_.find(item);
278 assert(found!=
map_.end());
279 if (found->second > 1) {
289 template<
typename T,
class Compare>
297 template<
typename T,
class Compare>