7 #ifndef INCLUDE_MOLASSEMBLER_TEMPLE_STRONG_INDEX_MAP_H
8 #define INCLUDE_MOLASSEMBLER_TEMPLE_STRONG_INDEX_MAP_H
15 namespace Molassembler {
18 template<
typename T,
typename U>
24 using iterator =
typename std::vector<U>::iterator;
25 using const_iterator =
typename std::vector<U>::const_iterator;
30 : map_(std::begin(weak), std::end(weak)) {}
32 T indexOf(
const U u)
const {
39 if(findIter == std::end(map_)) {
40 throw std::out_of_range(
"Item not found");
43 return T(findIter - std::begin(map_));
46 void resize(
unsigned newSize) {
50 unsigned size()
const {
58 const U& at(
const T t)
const {
66 void pushIsometric() {
67 map_.emplace_back(map_.size());
75 const unsigned N = map_.size();
76 std::vector<T> inverted(N);
77 for(
unsigned i = 0; i < N; ++i) {
78 inverted.at(map_.at(i)) = T(i);
83 iterator begin() {
return std::begin(map_); }
84 iterator end() {
return std::end(map_); }
85 const_iterator begin()
const {
return std::begin(map_); }
86 const_iterator end()
const {
return std::end(map_); }
89 return map_ == other.map_;
93 return map_ != other.map_;
Definition: StrongIndexMap.h:19
auto find(const Container &container, const T &needle)
std::find shorthand
Definition: Functional.h:359