8#ifndef Sawyer_Container_Tracker_H 
    9#define Sawyer_Container_Tracker_H 
   11#include <Sawyer/Set.h> 
   12#include <Sawyer/Synchronization.h> 
   14#include <boost/unordered/unordered_set.hpp> 
   30    bool exists(
const Key &key)
 const {
 
   31        return set.exists(key);
 
   33    bool insert(
const Key &key) {
 
   34        return set.insert(key);
 
 
   44    std::vector<bool> bvec;
 
   49    bool exists(
const Key &key)
 const {
 
   50        return key < bvec.size() && bvec[key];
 
   52    bool insert(
const Key &key) {
 
   53        bool retval = !exists(key);
 
   54        if (key >= bvec.size())
 
   55            bvec.resize(key+1, 
false);
 
 
   67    boost::unordered_set<Key> set;
 
   72    bool exists(
const Key &key)
 const {
 
   73        return set.find(key) != set.end();
 
   75    bool insert(
const Key &key) {
 
   76        return set.insert(key).second;
 
 
  166template<
class T, 
class K = T, 
class Traits = TrackerTraits<K> >
 
  178    mutable SAWYER_THREAD_TRAITS::Mutex mutex_;         
 
  179    typename Traits::Index index_;
 
  186        SAWYER_THREAD_TRAITS::LockGuard lock(mutex_);
 
 
  197        SAWYER_THREAD_TRAITS::LockGuard lock(mutex_);
 
  198        return !index_.insert(key);
 
 
  213        SAWYER_THREAD_TRAITS::LockGuard lock(mutex_);
 
  214        return index_.exists(key);
 
 
  249        for (
size_t i = 0; i < vector.size(); ++i) {
 
  251                vector[nSaved++] = vector[i];
 
  253        vector.resize(nSaved);
 
 
 
Set-based index referenced by TrackerTraits.
 
Hash-based index referenced by TrackerTraits.
 
Vector-based index referenced by TrackerTraits.
 
Tracks whether something has been seen before.
 
K Key
Key type for the values represented by the tracker.
 
void clear()
Make this tracker forget everything it has seen.
 
bool wasSeen(const Value &value) const
Test whether a value has been encountered previously.
 
bool testAndSet(const Value &value)
Test and then insert the value.
 
bool operator()(const Value &value)
Unary operator is the same as testAndSet.
 
void removeIfSeen(std::vector< Value > &vector)
Remove and track items from a vector.
 
bool insert(const Value &value)
Cause this tracker to see a value.
 
T Value
Type of values represented by the tracker.
 
TrackerSetIndex< Key > Index
Type of index for storing member keys.