diff options
author | Oskar Haarklou Veileborg <ohv1020@hotmail.com> | 2023-01-12 10:22:46 +0100 |
---|---|---|
committer | Oskar Haarklou Veileborg <ohv1020@hotmail.com> | 2023-01-12 10:25:31 +0100 |
commit | a74b83e3f275e44f686066081c7fdb665180ff9e (patch) | |
tree | 1b38c8dd10962017a600b46d704b11cde3ba7c00 /immutable.go | |
parent | Ensure immutability of sets (and maps with SetMany) (diff) | |
download | pds-a74b83e3f275e44f686066081c7fdb665180ff9e.tar.gz pds-a74b83e3f275e44f686066081c7fdb665180ff9e.tar.xz |
sets & maps: remove varargs APIs & SetMany variants
The implementation behind the API is not more efficient than manually
looping over a data structure and inserting elements one-by-one.
Diffstat (limited to 'immutable.go')
-rw-r--r-- | immutable.go | 19 |
1 files changed, 0 insertions, 19 deletions
diff --git a/immutable.go b/immutable.go index 4a42e33..e43bc70 100644 --- a/immutable.go +++ b/immutable.go @@ -752,17 +752,6 @@ func (m *Map[K, V]) Set(key K, value V) *Map[K, V] { return m.set(key, value, false) } -// SetMany returns a map with the keys set to the new values. nil values are allowed. -// -// This function will return a new map even if the updated value is the same as -// the existing value because Map does not track value equality. -func (m *Map[K, V]) SetMany(entries map[K]V) *Map[K, V] { - for k, v := range entries { - m = m.Set(k, v) - } - return m -} - func (m *Map[K, V]) set(key K, value V, mutable bool) *Map[K, V] { // Set a hasher on the first value if one does not already exist. hasher := m.hasher @@ -1641,14 +1630,6 @@ func (m *SortedMap[K, V]) Set(key K, value V) *SortedMap[K, V] { return m.set(key, value, false) } -// SetMany returns a map with the keys set to the new values. -func (m *SortedMap[K, V]) SetMany(entries map[K]V) *SortedMap[K, V] { - for k, v := range entries { - m = m.Set(k, v) - } - return m -} - func (m *SortedMap[K, V]) set(key K, value V, mutable bool) *SortedMap[K, V] { // Set a comparer on the first value if one does not already exist. comparer := m.comparer |