Skip to content

Commit bb7acc9

Browse files
committed
Isolate the StreamSet from MapSet (SetDef interface{} deprecated)
1 parent 126891b commit bb7acc9

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

stream.go

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ func (streamSelf *StreamDef[T]) Get(i int) T {
243243

244244
// Set
245245

246+
/*
246247
// SetDef Set inspired by Collection utils
247248
type SetDef[T comparable, R comparable] interface {
248249
MapKey(fn TransformerFunctor[T, T]) SetDef[T, R]
@@ -266,6 +267,7 @@ type SetDef[T comparable, R comparable] interface {
266267
AsMap() map[T]R
267268
AsMapSet() *MapSetDef[T, R]
268269
}
270+
*/
269271

270272
// MapSetDef Set inspired by Collection utils
271273
type MapSetDef[T comparable, R comparable] map[T]R
@@ -298,7 +300,7 @@ func SetFromArrayInterface(list []interface{}) *MapSetDef[interface{}, interface
298300
}
299301

300302
// MapKey Map all keys of Set by function
301-
func (mapSetSelf *MapSetDef[T, R]) MapKey(fn TransformerFunctor[T, T]) SetDef[T, R] {
303+
func (mapSetSelf *MapSetDef[T, R]) MapKey(fn TransformerFunctor[T, T]) *MapSetDef[T, R] {
302304
result := make(MapSetDef[T, R], len(*mapSetSelf))
303305
for k, v := range *mapSetSelf {
304306
result[fn(k)] = v
@@ -308,7 +310,7 @@ func (mapSetSelf *MapSetDef[T, R]) MapKey(fn TransformerFunctor[T, T]) SetDef[T,
308310
}
309311

310312
// MapValue Map all values of Set by function
311-
func (mapSetSelf *MapSetDef[T, R]) MapValue(fn TransformerFunctor[R, R]) SetDef[T, R] {
313+
func (mapSetSelf *MapSetDef[T, R]) MapValue(fn TransformerFunctor[R, R]) *MapSetDef[T, R] {
312314
result := make(MapSetDef[T, R], len(*mapSetSelf))
313315
for k, v := range *mapSetSelf {
314316
result[k] = fn(v)
@@ -334,17 +336,17 @@ func (mapSetSelf *MapSetDef[T, R]) ContainsValue(input R) bool {
334336
}
335337

336338
// IsSubsetByKey returns true or false by checking if set1 is a subset of set2
337-
func (mapSetSelf *MapSetDef[T, R]) IsSubsetByKey(input SetDef[T, R]) bool {
339+
func (mapSetSelf *MapSetDef[T, R]) IsSubsetByKey(input *MapSetDef[T, R]) bool {
338340
return IsSubsetMapByKey(*mapSetSelf, input.AsMap())
339341
}
340342

341343
// IsSupersetByKey returns true or false by checking if set1 is a superset of set2
342-
func (mapSetSelf *MapSetDef[T, R]) IsSupersetByKey(input SetDef[T, R]) bool {
344+
func (mapSetSelf *MapSetDef[T, R]) IsSupersetByKey(input *MapSetDef[T, R]) bool {
343345
return IsSupersetMapByKey(*mapSetSelf, input.AsMap())
344346
}
345347

346348
// Add Add items into the Set
347-
func (mapSetSelf *MapSetDef[T, R]) Add(input ...T) SetDef[T, R] {
349+
func (mapSetSelf *MapSetDef[T, R]) Add(input ...T) *MapSetDef[T, R] {
348350
inputLen := len(input)
349351
if inputLen > 0 {
350352
result := mapSetSelf.Clone()
@@ -362,7 +364,7 @@ func (mapSetSelf *MapSetDef[T, R]) Add(input ...T) SetDef[T, R] {
362364
}
363365

364366
// RemoveKeys Remove keys from the Set
365-
func (mapSetSelf *MapSetDef[T, R]) RemoveKeys(input ...T) SetDef[T, R] {
367+
func (mapSetSelf *MapSetDef[T, R]) RemoveKeys(input ...T) *MapSetDef[T, R] {
366368
inputLen := len(input)
367369
if inputLen > 0 {
368370
result := mapSetSelf.Clone()
@@ -377,7 +379,7 @@ func (mapSetSelf *MapSetDef[T, R]) RemoveKeys(input ...T) SetDef[T, R] {
377379
}
378380

379381
// RemoveValues Remove values from the Set
380-
func (mapSetSelf *MapSetDef[T, R]) RemoveValues(input ...R) SetDef[T, R] {
382+
func (mapSetSelf *MapSetDef[T, R]) RemoveValues(input ...R) *MapSetDef[T, R] {
381383
inputLen := len(input)
382384
if inputLen > 0 {
383385
result := mapSetSelf.Clone()
@@ -407,14 +409,14 @@ func (mapSetSelf *MapSetDef[T, R]) Set(key T, value R) {
407409
}
408410

409411
// Clone Clone this Set
410-
func (mapSetSelf *MapSetDef[T, R]) Clone() SetDef[T, R] {
412+
func (mapSetSelf *MapSetDef[T, R]) Clone() *MapSetDef[T, R] {
411413
result := MapSetDef[T, R](DuplicateMap[T, R](*mapSetSelf))
412414

413415
return &result
414416
}
415417

416418
// Union Union an another Set object
417-
func (mapSetSelf *MapSetDef[T, R]) Union(input SetDef[T, R]) SetDef[T, R] {
419+
func (mapSetSelf *MapSetDef[T, R]) Union(input *MapSetDef[T, R]) *MapSetDef[T, R] {
418420
if input == nil || input.Size() == 0 {
419421
return mapSetSelf
420422
}
@@ -425,7 +427,7 @@ func (mapSetSelf *MapSetDef[T, R]) Union(input SetDef[T, R]) SetDef[T, R] {
425427
}
426428

427429
// Intersection Get the Intersection with this Set and an another Set
428-
func (mapSetSelf *MapSetDef[T, R]) Intersection(input SetDef[T, R]) SetDef[T, R] {
430+
func (mapSetSelf *MapSetDef[T, R]) Intersection(input *MapSetDef[T, R]) *MapSetDef[T, R] {
429431
if input == nil || input.Size() == 0 {
430432
return new(MapSetDef[T, R])
431433
}
@@ -436,7 +438,7 @@ func (mapSetSelf *MapSetDef[T, R]) Intersection(input SetDef[T, R]) SetDef[T, R]
436438
}
437439

438440
// Minus Get all of this Set but not in the given Set
439-
func (mapSetSelf *MapSetDef[T, R]) Minus(input SetDef[T, R]) SetDef[T, R] {
441+
func (mapSetSelf *MapSetDef[T, R]) Minus(input *MapSetDef[T, R]) *MapSetDef[T, R] {
440442
if input == nil || input.Size() == 0 {
441443
return mapSetSelf
442444
}

0 commit comments

Comments
 (0)