mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-10-29 18:52:30 +00:00 
			
		
		
		
	hashlib, rtlil: Add operator+=() to dict<>::iterator and dict<>::const_iterator and add operator+() and operator+=() to ObjIterator.
				
					
				
			This commit is contained in:
		
							parent
							
								
									d5d0cc88d2
								
							
						
					
					
						commit
						e5a2d17b5d
					
				
					 2 changed files with 25 additions and 0 deletions
				
			
		|  | @ -363,6 +363,7 @@ public: | ||||||
| 	public: | 	public: | ||||||
| 		const_iterator() { } | 		const_iterator() { } | ||||||
| 		const_iterator operator++() { index--; return *this; } | 		const_iterator operator++() { index--; return *this; } | ||||||
|  | 		const_iterator operator+=(int amt) { index -= amt; if(index < 0) index = -1; return *this; } | ||||||
| 		bool operator<(const const_iterator &other) const { return index > other.index; } | 		bool operator<(const const_iterator &other) const { return index > other.index; } | ||||||
| 		bool operator==(const const_iterator &other) const { return index == other.index; } | 		bool operator==(const const_iterator &other) const { return index == other.index; } | ||||||
| 		bool operator!=(const const_iterator &other) const { return index != other.index; } | 		bool operator!=(const const_iterator &other) const { return index != other.index; } | ||||||
|  | @ -380,6 +381,7 @@ public: | ||||||
| 	public: | 	public: | ||||||
| 		iterator() { } | 		iterator() { } | ||||||
| 		iterator operator++() { index--; return *this; } | 		iterator operator++() { index--; return *this; } | ||||||
|  | 		iterator operator+=(int amt) { index -= amt; if(index < 0) index = -1; return *this; } | ||||||
| 		bool operator<(const iterator &other) const { return index > other.index; } | 		bool operator<(const iterator &other) const { return index > other.index; } | ||||||
| 		bool operator==(const iterator &other) const { return index == other.index; } | 		bool operator==(const iterator &other) const { return index == other.index; } | ||||||
| 		bool operator!=(const iterator &other) const { return index != other.index; } | 		bool operator!=(const iterator &other) const { return index != other.index; } | ||||||
|  |  | ||||||
|  | @ -554,6 +554,29 @@ namespace RTLIL | ||||||
| 			return *this; | 			return *this; | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
|  | 		inline ObjIterator<T>& operator+=(int amt) { | ||||||
|  | 			log_assert(list_p != nullptr); | ||||||
|  | 			it += amt; | ||||||
|  | 			if (it == list_p->end()) { | ||||||
|  | 				(*refcount_p)--; | ||||||
|  | 				list_p = nullptr; | ||||||
|  | 				refcount_p = nullptr; | ||||||
|  | 			} | ||||||
|  | 			return *this; | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
|  | 		inline ObjIterator<T> operator+(int amt) { | ||||||
|  | 			log_assert(list_p != nullptr); | ||||||
|  | 			ObjIterator<T> new_obj(*this); | ||||||
|  | 			new_obj.it += amt; | ||||||
|  | 			if (new_obj.it == list_p->end()) { | ||||||
|  | 				(*(new_obj.refcount_p))--; | ||||||
|  | 				new_obj.list_p = nullptr; | ||||||
|  | 				new_obj.refcount_p = nullptr; | ||||||
|  | 			} | ||||||
|  | 			return new_obj; | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
| 		inline const ObjIterator<T> operator++(int) { | 		inline const ObjIterator<T> operator++(int) { | ||||||
| 			ObjIterator<T> result(*this); | 			ObjIterator<T> result(*this); | ||||||
| 			++(*this); | 			++(*this); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue