Changeset fc1a3e2 for src/Common
- Timestamp:
- Apr 19, 2024, 2:36:52 PM (5 months ago)
- Branches:
- master
- Children:
- ba97ebf
- Parents:
- b9b6efb
- Location:
- src/Common
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Common/PersistentMap.h
rb9b6efb rfc1a3e2 23 23 #include <utility> // for forward, move 24 24 25 /// Wraps a hash table in a persistent data structure, using a technique based 26 /// on the persistent array in Conchon & Filliatre "A Persistent Union-Find 25 /// Wraps a hash table in a persistent data structure, using a technique based 26 /// on the persistent array in Conchon & Filliatre "A Persistent Union-Find 27 27 /// Data Structure" 28 28 29 29 template<typename Key, typename Val, 30 31 class PersistentMap 30 typename Hash = std::hash<Key>, typename Eq = std::equal_to<Key>> 31 class PersistentMap 32 32 : public std::enable_shared_from_this<PersistentMap<Key, Val, Hash, Eq>> { 33 33 public: … … 38 38 39 39 /// Types of version nodes 40 enum Mode { 40 enum Mode { 41 41 BASE, ///< Root node of version tree 42 42 REM, ///< Key removal node … … 63 63 Ptr base; ///< Modified map 64 64 Key key; ///< Key removed 65 65 66 66 template<typename P, typename K> 67 67 Rem(P&& p, K&& k) : base(std::forward<P>(p)), key(std::forward<K>(k)) {} … … 155 155 auto it = base_map.find( self.key ); 156 156 157 base->template init<Ins>( 157 base->template init<Ins>( 158 158 mut_this->shared_from_this(), std::move(self.key), std::move(it->second) ); 159 159 base->mode = INS; … … 175 175 auto it = base_map.find( self.key ); 176 176 177 base->template init<Ins>( 177 base->template init<Ins>( 178 178 mut_this->shared_from_this(), std::move(self.key), std::move(it->second) ); 179 179 base->mode = UPD; … … 267 267 Ptr erase(const Key& k) { 268 268 reroot(); 269 269 270 270 // exit early if key does not exist in map 271 271 if ( ! as<Base>().count( k ) ) return this->shared_from_this(); -
src/Common/VectorMap.h
rb9b6efb rfc1a3e2 36 36 typedef const value_type* pointer; 37 37 typedef const const_value_type* const_pointer; 38 39 class iterator : public std::iterator< std::random_access_iterator_tag, 40 value_type, 41 difference_type, 42 pointer, 43 reference > { 44 friend class VectorMap; 45 friend class const_iterator; 46 38 39 class iterator : public std::iterator< 40 std::random_access_iterator_tag, 41 value_type, difference_type, pointer, reference > { 42 friend class VectorMap; 43 friend class const_iterator; 44 47 45 value_type data; 48 46 … … 99 97 return data.first == o.data.first && &data.second == &o.data.second; 100 98 } 101 99 102 100 bool operator!= (const iterator& that) const { return !(*this == that); } 103 101 … … 111 109 }; 112 110 113 class const_iterator : public std::iterator< std::bidirectional_iterator_tag, 114 const_value_type, 115 difference_type, 116 const_pointer, 117 const_reference > { 118 friend class VectorMap; 111 class const_iterator : public std::iterator< 112 std::bidirectional_iterator_tag, 113 const_value_type, difference_type, const_pointer, const_reference > { 114 friend class VectorMap; 119 115 const_value_type data; 120 116 … … 181 177 return data.first == o.data.first && &data.second == &o.data.second; 182 178 } 183 179 184 180 bool operator!= (const const_iterator& that) const { return !(*this == that); } 185 181 … … 233 229 234 230 template<typename T> 235 typename VectorMap<T>::iterator operator+ (typename VectorMap<T>::difference_type i, 236 const typename VectorMap<T>::iterator& it) { 231 typename VectorMap<T>::iterator operator+( 232 typename VectorMap<T>::difference_type i, 233 const typename VectorMap<T>::iterator& it) { 237 234 return it + i; 238 235 } 239 236 240 237 template<typename T> 241 typename VectorMap<T>::const_iterator operator+ (typename VectorMap<T>::difference_type i, 242 const typename VectorMap<T>::const_iterator& it) { 238 typename VectorMap<T>::const_iterator operator+( 239 typename VectorMap<T>::difference_type i, 240 const typename VectorMap<T>::const_iterator& it) { 243 241 return it + i; 244 242 }
Note: See TracChangeset
for help on using the changeset viewer.