{"repo":"elliotchance/orderedmap","free":true,"listed":false,"github":"https://github.com/elliotchance/orderedmap","clone":"git clone https://github.com/elliotchance/orderedmap.git","description":"🔃 An ordered map in Go with amortized O(1) for Set, Get, Delete and Len.","language":"Go","stars":1025,"topics":["golang","data-structures","maps","orderedmap"],"license":"MIT","category":"dev-tools","readme_excerpt":"🔃 github.com/elliotchance/orderedmap/v3 Basic Usage An OrderedMap is a high performance ordered map that maintains amortized O(1) for Set , Get , Delete and Len : [!NOTE] - v3 requires Go v1.23 - If you need to support Go 1.18-1.22, you can use v2. - v2 requires Go v1.18 for generics - If you need to support Go 1.17 or below, you can use v1. Internally an OrderedMap uses the composite type map combined with a trimmed down linked list to maintain the order. Iterating The following methods all return iterators that can be used to loop over elements in an ordered map: - AllFromFront() - AllFromBack() - Keys() - Values() Iterators are safe to use bidirectionally, and will return nil once it goes beyond the first or last item. If the map is changing while the iteration is in-flight it may produce unexpected behavior. If you want to get a slice of the map keys or values, you can use the standard slices.Collect method with the iterator returned from Keys() or Values() : Likewise, calling maps.Collect on the iterator returned from AllFromFront() will create a regular unordered map from the ordered one: If you don't want to use iterators, you can also manually loop over the elements using Front() or Back() with Next() :","default_branch":null,"files":null,"tree":[],"storefront":"/r/elliotchance","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/elliotchance/orderedmap/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}