All Classes Namespaces Functions Pages
halPositionCache.h
/*
* Copyright (C) 2012 by Glenn Hickey (hickey@soe.ucsc.edu)
*
* Released under the MIT license, see LICENSE.txt
*/
#ifndef _HALPOSITIONCACHE_H
#define _HALPOSITIONCACHE_H
#include <map>
#include <map>
#include <string>
#include <vector>
#include <cassert>
#include "hal.h"
namespace hal {
class PositionCache
{
public:
PositionCache() : _size(0), _prev(_set.begin()) {}
// sorted by last index, so each interval is (last, first)
typedef std::map<hal_index_t, hal_index_t> IntervalSet;
bool insert(hal_index_t pos);
bool find(hal_index_t pos) const;
void clear();
bool check() const;
hal_size_t size() const { return _size; }
hal_size_t numIntervals() const { return _set.size(); }
const IntervalSet* getIntervalSet() { return &_set; }
protected:
IntervalSet _set;
hal_size_t _size;
IntervalSet::iterator _prev;
};
}
#endif
hal::PositionCache
Definition: halPositionCache.h:23