Skip to content

Commit 508a2b2

Browse files
committed
added FoldHalfGroup to AList/ASet C# interface
1 parent 425e811 commit 508a2b2

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

src/CSharp.Data.Adaptive/AList.fs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,12 @@ type AdaptiveIndexList private() =
234234
let subFun = fun s -> fun a -> sub.Invoke(s, a)
235235
this |> AList.reduce (AdaptiveReduction.group zero addFun subFun)
236236

237+
[<Extension; MethodImpl(MethodImplOptions.AggressiveInlining)>]
238+
static member FoldHalfGroup<'T1, 'T2>(this: alist<'T1>, add: Func<'T2, 'T1, 'T2>, sub: Func<'T2, 'T1, ValueOption<'T2>>, zero: 'T2) =
239+
let addFun = fun s -> fun a -> add.Invoke(s, a)
240+
let subFun = fun s -> fun a -> sub.Invoke(s, a)
241+
this |> AList.reduce (AdaptiveReduction.halfGroup zero addFun subFun)
242+
237243
[<Extension; MethodImpl(MethodImplOptions.AggressiveInlining)>]
238244
static member Indexed(this: alist<'T>) =
239245
this |> AList.indexed

src/CSharp.Data.Adaptive/ASet.fs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,12 @@ type AdaptiveHashSet private() =
239239
let addFun = fun s -> fun a -> add.Invoke(s, a)
240240
let subFun = fun s -> fun a -> sub.Invoke(s, a)
241241
this |> ASet.reduce (AdaptiveReduction.group zero addFun subFun)
242+
243+
[<Extension; MethodImpl(MethodImplOptions.AggressiveInlining)>]
244+
static member FoldHalfGroup<'T1, 'T2>(this: aset<'T1>, add: Func<'T2, 'T1, 'T2>, sub: Func<'T2, 'T1, ValueOption<'T2>>, zero: 'T2) =
245+
let addFun = fun s -> fun a -> add.Invoke(s, a)
246+
let subFun = fun s -> fun a -> sub.Invoke(s, a)
247+
this |> ASet.reduce (AdaptiveReduction.halfGroup zero addFun subFun)
242248

243249
[<Extension; MethodImpl(MethodImplOptions.AggressiveInlining)>]
244250
static member SortBy(this: aset<'T>, projection: Func<'T, 'C>) =

0 commit comments

Comments
 (0)