I have below a description of a data structure I need and I want to implement it using immutable data structures. I\'m trying to determine... is there an existing data struc
Without knowing more about your requirements, I'd just say a vanilla Set<'a> does a more than adequate job. I'd prefer a 'Set' over a 'List' so you always have O(lg n) access to the largest and smallest items, allowing you to ordered your set by insert date/time for efficient access to the newest and oldest items.
Seems very easy to wrap up a set so that its Add/Remove methods invoke your callbacks:
type AwesomeSet(internalSet : Set<'a>, insertCallback : 'a -> unit, removeCallback : 'a -> unit) =
member this.Add(x) =
insertCallback(x)
AwesomeSet(internalSet.Add x, insertCallback, removeCallback)
member this.Remove(x) =
removeCallback(x)
AwesomeSet(internalSet.Remove x, insertCallback, removeCallback)
member this.Count = internalSet.Count
member this.Min = internalSet.MinimumElement
member this.Max = internalSet.MaximumElement