Skip to content

Commit

Permalink
[skip ci] Committing a half-completed experiment to replace the tuple…
Browse files Browse the repository at this point in the history
… type used as the element type of the AVL tree used to implement CharDiet with a struct to see if there's any noticeable performance improvement. I'll finish the experiment later, but I don't want to forget about it and the changes are both minimal and commented out so there's no difference in functionality.
  • Loading branch information
jack-pappas committed Aug 16, 2015
1 parent 045cf0a commit 24ec3ff
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions Reggie/Collections.fs
Expand Up @@ -703,19 +703,35 @@ and [<Sealed>]
AvlTree.ToArray avlTree


///// A closed interval.
//[<Struct>]
//type ClosedInterval<'T when 'T :> System.IComparable<'T>> (a : 'T, b : 'T) =
// /// The left endpoint of the interval.
// member __.A = a
// /// The right endpoint of the interval.
// member __.B = b

/// A Discrete Interval Encoding Tree (DIET) specialized to the 'char' type.
/// This is abbreviated in our documentation as a 'char-DIET'.
//type CharDiet = AvlTree<ClosedInterval<char>>
type CharDiet = AvlTree<char * char>

/// Functional operations for char-DIETs.
[<RequireQualifiedAccess; CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
module CharDiet =
open System.Collections.Generic
open LanguagePrimitives

/// Character interval comparer.
/// This doesn't do a real interval-algebra comparison -- it's only
/// a simple lexicographic ordering.
let comparer =
LanguagePrimitives.FastGenericComparer<char * char>
// { new System.Collections.Generic.IComparer<ClosedInterval<char>> with
// member __.Compare (x, y) =
// match compare x.A y.A with
// | 0 ->
// compare x.B y.B
// | x ->
// x
// }

/// Returns the predecessor of the given value.
let inline private pred (c : char) : char =
Expand Down

0 comments on commit 24ec3ff

Please sign in to comment.