@@ -160,6 +160,21 @@ func (slice intSlicePtr) DistinctPtr() intSlicePtr {
160
160
return DistinctIntPtr (slice )
161
161
}
162
162
163
+ //TakeWhile - Returns a new list based on predicate function. It returns new list once condition fails.
164
+ func (slice intSlice ) TakeWhile (functors ... intFunctorForFilter ) intSlice {
165
+
166
+ tmpSlice := slice
167
+
168
+ for _ , f := range functors {
169
+ if f == nil {
170
+ continue
171
+ }
172
+ tmpSlice = TakeWhileInt (f , tmpSlice )
173
+ }
174
+
175
+ return tmpSlice
176
+ }
177
+
163
178
type int64Slice []int64
164
179
type int64FunctorForMap func (int64 ) int64
165
180
type int64FunctorForFilter func (int64 ) bool
@@ -320,6 +335,21 @@ func (slice int64SlicePtr) DistinctPtr() int64SlicePtr {
320
335
return DistinctInt64Ptr (slice )
321
336
}
322
337
338
+ //TakeWhile - Returns a new list based on predicate function. It returns new list once condition fails.
339
+ func (slice int64Slice ) TakeWhile (functors ... int64FunctorForFilter ) int64Slice {
340
+
341
+ tmpSlice := slice
342
+
343
+ for _ , f := range functors {
344
+ if f == nil {
345
+ continue
346
+ }
347
+ tmpSlice = TakeWhileInt64 (f , tmpSlice )
348
+ }
349
+
350
+ return tmpSlice
351
+ }
352
+
323
353
type int32Slice []int32
324
354
type int32FunctorForMap func (int32 ) int32
325
355
type int32FunctorForFilter func (int32 ) bool
@@ -480,6 +510,21 @@ func (slice int32SlicePtr) DistinctPtr() int32SlicePtr {
480
510
return DistinctInt32Ptr (slice )
481
511
}
482
512
513
+ //TakeWhile - Returns a new list based on predicate function. It returns new list once condition fails.
514
+ func (slice int32Slice ) TakeWhile (functors ... int32FunctorForFilter ) int32Slice {
515
+
516
+ tmpSlice := slice
517
+
518
+ for _ , f := range functors {
519
+ if f == nil {
520
+ continue
521
+ }
522
+ tmpSlice = TakeWhileInt32 (f , tmpSlice )
523
+ }
524
+
525
+ return tmpSlice
526
+ }
527
+
483
528
type int16Slice []int16
484
529
type int16FunctorForMap func (int16 ) int16
485
530
type int16FunctorForFilter func (int16 ) bool
@@ -640,6 +685,21 @@ func (slice int16SlicePtr) DistinctPtr() int16SlicePtr {
640
685
return DistinctInt16Ptr (slice )
641
686
}
642
687
688
+ //TakeWhile - Returns a new list based on predicate function. It returns new list once condition fails.
689
+ func (slice int16Slice ) TakeWhile (functors ... int16FunctorForFilter ) int16Slice {
690
+
691
+ tmpSlice := slice
692
+
693
+ for _ , f := range functors {
694
+ if f == nil {
695
+ continue
696
+ }
697
+ tmpSlice = TakeWhileInt16 (f , tmpSlice )
698
+ }
699
+
700
+ return tmpSlice
701
+ }
702
+
643
703
type int8Slice []int8
644
704
type int8FunctorForMap func (int8 ) int8
645
705
type int8FunctorForFilter func (int8 ) bool
@@ -800,6 +860,21 @@ func (slice int8SlicePtr) DistinctPtr() int8SlicePtr {
800
860
return DistinctInt8Ptr (slice )
801
861
}
802
862
863
+ //TakeWhile - Returns a new list based on predicate function. It returns new list once condition fails.
864
+ func (slice int8Slice ) TakeWhile (functors ... int8FunctorForFilter ) int8Slice {
865
+
866
+ tmpSlice := slice
867
+
868
+ for _ , f := range functors {
869
+ if f == nil {
870
+ continue
871
+ }
872
+ tmpSlice = TakeWhileInt8 (f , tmpSlice )
873
+ }
874
+
875
+ return tmpSlice
876
+ }
877
+
803
878
type uintSlice []uint
804
879
type uintFunctorForMap func (uint ) uint
805
880
type uintFunctorForFilter func (uint ) bool
@@ -960,6 +1035,21 @@ func (slice uintSlicePtr) DistinctPtr() uintSlicePtr {
960
1035
return DistinctUintPtr (slice )
961
1036
}
962
1037
1038
+ //TakeWhile - Returns a new list based on predicate function. It returns new list once condition fails.
1039
+ func (slice uintSlice ) TakeWhile (functors ... uintFunctorForFilter ) uintSlice {
1040
+
1041
+ tmpSlice := slice
1042
+
1043
+ for _ , f := range functors {
1044
+ if f == nil {
1045
+ continue
1046
+ }
1047
+ tmpSlice = TakeWhileUint (f , tmpSlice )
1048
+ }
1049
+
1050
+ return tmpSlice
1051
+ }
1052
+
963
1053
type uint64Slice []uint64
964
1054
type uint64FunctorForMap func (uint64 ) uint64
965
1055
type uint64FunctorForFilter func (uint64 ) bool
@@ -1120,6 +1210,21 @@ func (slice uint64SlicePtr) DistinctPtr() uint64SlicePtr {
1120
1210
return DistinctUint64Ptr (slice )
1121
1211
}
1122
1212
1213
+ //TakeWhile - Returns a new list based on predicate function. It returns new list once condition fails.
1214
+ func (slice uint64Slice ) TakeWhile (functors ... uint64FunctorForFilter ) uint64Slice {
1215
+
1216
+ tmpSlice := slice
1217
+
1218
+ for _ , f := range functors {
1219
+ if f == nil {
1220
+ continue
1221
+ }
1222
+ tmpSlice = TakeWhileUint64 (f , tmpSlice )
1223
+ }
1224
+
1225
+ return tmpSlice
1226
+ }
1227
+
1123
1228
type uint32Slice []uint32
1124
1229
type uint32FunctorForMap func (uint32 ) uint32
1125
1230
type uint32FunctorForFilter func (uint32 ) bool
@@ -1280,6 +1385,21 @@ func (slice uint32SlicePtr) DistinctPtr() uint32SlicePtr {
1280
1385
return DistinctUint32Ptr (slice )
1281
1386
}
1282
1387
1388
+ //TakeWhile - Returns a new list based on predicate function. It returns new list once condition fails.
1389
+ func (slice uint32Slice ) TakeWhile (functors ... uint32FunctorForFilter ) uint32Slice {
1390
+
1391
+ tmpSlice := slice
1392
+
1393
+ for _ , f := range functors {
1394
+ if f == nil {
1395
+ continue
1396
+ }
1397
+ tmpSlice = TakeWhileUint32 (f , tmpSlice )
1398
+ }
1399
+
1400
+ return tmpSlice
1401
+ }
1402
+
1283
1403
type uint16Slice []uint16
1284
1404
type uint16FunctorForMap func (uint16 ) uint16
1285
1405
type uint16FunctorForFilter func (uint16 ) bool
@@ -1440,6 +1560,21 @@ func (slice uint16SlicePtr) DistinctPtr() uint16SlicePtr {
1440
1560
return DistinctUint16Ptr (slice )
1441
1561
}
1442
1562
1563
+ //TakeWhile - Returns a new list based on predicate function. It returns new list once condition fails.
1564
+ func (slice uint16Slice ) TakeWhile (functors ... uint16FunctorForFilter ) uint16Slice {
1565
+
1566
+ tmpSlice := slice
1567
+
1568
+ for _ , f := range functors {
1569
+ if f == nil {
1570
+ continue
1571
+ }
1572
+ tmpSlice = TakeWhileUint16 (f , tmpSlice )
1573
+ }
1574
+
1575
+ return tmpSlice
1576
+ }
1577
+
1443
1578
type uint8Slice []uint8
1444
1579
type uint8FunctorForMap func (uint8 ) uint8
1445
1580
type uint8FunctorForFilter func (uint8 ) bool
@@ -1600,6 +1735,21 @@ func (slice uint8SlicePtr) DistinctPtr() uint8SlicePtr {
1600
1735
return DistinctUint8Ptr (slice )
1601
1736
}
1602
1737
1738
+ //TakeWhile - Returns a new list based on predicate function. It returns new list once condition fails.
1739
+ func (slice uint8Slice ) TakeWhile (functors ... uint8FunctorForFilter ) uint8Slice {
1740
+
1741
+ tmpSlice := slice
1742
+
1743
+ for _ , f := range functors {
1744
+ if f == nil {
1745
+ continue
1746
+ }
1747
+ tmpSlice = TakeWhileUint8 (f , tmpSlice )
1748
+ }
1749
+
1750
+ return tmpSlice
1751
+ }
1752
+
1603
1753
type stringSlice []string
1604
1754
type stringFunctorForMap func (string ) string
1605
1755
type stringFunctorForFilter func (string ) bool
@@ -1760,6 +1910,21 @@ func (slice stringSlicePtr) DistinctPtr() stringSlicePtr {
1760
1910
return DistinctStrPtr (slice )
1761
1911
}
1762
1912
1913
+ //TakeWhile - Returns a new list based on predicate function. It returns new list once condition fails.
1914
+ func (slice stringSlice ) TakeWhile (functors ... stringFunctorForFilter ) stringSlice {
1915
+
1916
+ tmpSlice := slice
1917
+
1918
+ for _ , f := range functors {
1919
+ if f == nil {
1920
+ continue
1921
+ }
1922
+ tmpSlice = TakeWhileStr (f , tmpSlice )
1923
+ }
1924
+
1925
+ return tmpSlice
1926
+ }
1927
+
1763
1928
type boolSlice []bool
1764
1929
type boolFunctorForMap func (bool ) bool
1765
1930
type boolFunctorForFilter func (bool ) bool
@@ -1920,6 +2085,21 @@ func (slice boolSlicePtr) DistinctPtr() boolSlicePtr {
1920
2085
return DistinctBoolPtr (slice )
1921
2086
}
1922
2087
2088
+ //TakeWhile - Returns a new list based on predicate function. It returns new list once condition fails.
2089
+ func (slice boolSlice ) TakeWhile (functors ... boolFunctorForFilter ) boolSlice {
2090
+
2091
+ tmpSlice := slice
2092
+
2093
+ for _ , f := range functors {
2094
+ if f == nil {
2095
+ continue
2096
+ }
2097
+ tmpSlice = TakeWhileBool (f , tmpSlice )
2098
+ }
2099
+
2100
+ return tmpSlice
2101
+ }
2102
+
1923
2103
type float32Slice []float32
1924
2104
type float32FunctorForMap func (float32 ) float32
1925
2105
type float32FunctorForFilter func (float32 ) bool
@@ -2080,6 +2260,21 @@ func (slice float32SlicePtr) DistinctPtr() float32SlicePtr {
2080
2260
return DistinctFloat32Ptr (slice )
2081
2261
}
2082
2262
2263
+ //TakeWhile - Returns a new list based on predicate function. It returns new list once condition fails.
2264
+ func (slice float32Slice ) TakeWhile (functors ... float32FunctorForFilter ) float32Slice {
2265
+
2266
+ tmpSlice := slice
2267
+
2268
+ for _ , f := range functors {
2269
+ if f == nil {
2270
+ continue
2271
+ }
2272
+ tmpSlice = TakeWhileFloat32 (f , tmpSlice )
2273
+ }
2274
+
2275
+ return tmpSlice
2276
+ }
2277
+
2083
2278
type float64Slice []float64
2084
2279
type float64FunctorForMap func (float64 ) float64
2085
2280
type float64FunctorForFilter func (float64 ) bool
@@ -2239,3 +2434,18 @@ func (slice float64Slice) Distinct() float64Slice {
2239
2434
func (slice float64SlicePtr ) DistinctPtr () float64SlicePtr {
2240
2435
return DistinctFloat64Ptr (slice )
2241
2436
}
2437
+
2438
+ //TakeWhile - Returns a new list based on predicate function. It returns new list once condition fails.
2439
+ func (slice float64Slice ) TakeWhile (functors ... float64FunctorForFilter ) float64Slice {
2440
+
2441
+ tmpSlice := slice
2442
+
2443
+ for _ , f := range functors {
2444
+ if f == nil {
2445
+ continue
2446
+ }
2447
+ tmpSlice = TakeWhileFloat64 (f , tmpSlice )
2448
+ }
2449
+
2450
+ return tmpSlice
2451
+ }
0 commit comments