halapi
hierarchichalalignmentformatapi
 All Classes Namespaces Functions Pages
halPositionCache.h
1 /*
2  * Copyright (C) 2012 by Glenn Hickey (hickey@soe.ucsc.edu)
3  *
4  * Released under the MIT license, see LICENSE.txt
5  */
6 
7 #ifndef _HALPOSITIONCACHE_H
8 #define _HALPOSITIONCACHE_H
9 
10 #include <map>
11 #include <map>
12 #include <string>
13 #include <vector>
14 #include <cassert>
15 #include "hal.h"
16 
17 namespace hal {
18 
24 {
25 public:
26  PositionCache() : _size(0), _prev(_set.begin()) {}
27 
28  // sorted by last index, so each interval is (last, first)
29  typedef std::map<hal_index_t, hal_index_t> IntervalSet;
30 
31  bool insert(hal_index_t pos);
32  bool find(hal_index_t pos) const;
33  void clear();
34  bool check() const;
35  hal_size_t size() const { return _size; }
36  hal_size_t numIntervals() const { return _set.size(); }
37 
38  const IntervalSet* getIntervalSet() { return &_set; }
39 
40 protected:
41 
42  IntervalSet _set;
43  hal_size_t _size;
44  IntervalSet::iterator _prev;
45 };
46 
47 }
48 
49 #endif
50 
Definition: halPositionCache.h:23