Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serokell: [Milestone-1] New PersistentOrderedMap.mo lib #654

Closed
wants to merge 11 commits into from

Commits on Oct 21, 2024

  1. Extract persistent RBTree from mutable wrapper into a separate module

    No changes in logic so far, just simple refactoring
    s-and-witch authored and GoPavel committed Oct 21, 2024
    Configuration menu
    Copy the full SHA
    d97833b View commit details
    Browse the repository at this point in the history
  2. [DMS-66] Extend API for persistent ordered map

    Add `MapOps` class with the following signature:
    
      public class MapOps<K>(compare : (K,K) -> O.Order) {
    
        public func put<V>(rbMap : Map<K, V>, key : K, value : V) : Map<K, V>
    
        public func fromIter<V>(i : I.Iter<(K,V)>) : Map<K, V>
    
        public func replace<V>(rbMap : Map<K, V>, key : K, value : V) : (Map<K,V>, ?V)
    
        public func mapFilter<V1, V2>(f : (K, V1) -> ?V2, rbMap : Map<K, V1>) : Map<K, V2>
    
        public func get<V>(key : K, rbMap : Map<K, V>) : ?V
    
        public func delete<V>(rbMap : Map<K, V>, key : K) : Map<K, V>
    
        public func remove< V>(rbMap : Map<K, V>, key : K) : (Map<K,V>, ?V)
    
      };
    
    The other functionality provided as standalone functions, as they
    don't require comparator:
    
      public type Direction = { #fwd; #bwd };
    
      public func iter<K, V>(rbMap : Map<K, V>, direction : Direction) : I.Iter<(K, V)>
    
      public func entries<K, V>(m : Map<K, V>) : I.Iter<(K, V)>
    
      public func keys<K, V>(m : Map<K, V>, direction : Direction) : I.Iter<K>
    
      public func vals<K, V>(m : Map<K, V>, direction : Direction) : I.Iter<V>
    
      public func map<K, V1, V2>(f : (K, V1) -> V2, rbMap : Map<K, V1>) : Map<K, V2>
    
      public func size<K, V>(t : Map<K, V>) : Nat
    
      public func foldLeft<Key, Value, Accum>(
        combine : (Key, Value, Accum) -> Accum,
        base : Accum,
        rbMap : Map<Key, Value>
      ) : Accum
    
      And foldRight with the same signature as foldLeft
    
    The following functions are new for the API:
    - MapOps.put, MapOps.delete
    - MapOps.fromIter, entries, keys, vals
    - MapOps.mapFilter, map
    - foldLeft, foldRight
    s-and-witch authored and GoPavel committed Oct 21, 2024
    Configuration menu
    Copy the full SHA
    14b886f View commit details
    Browse the repository at this point in the history
  3. [DMS-66] fix order of method arguments

    Problem: now order is not consistent within new module and with old
    modules as well.
    
    Solution: make the map argument always go first
    GoPavel committed Oct 21, 2024
    Configuration menu
    Copy the full SHA
    564f95a View commit details
    Browse the repository at this point in the history
  4. [DMS-76] Persistent ordered map unit testing

    In addition to tests this patch removes `direction`
    argument from `keys` and `values` function to keep
    them simple and provides a new function `Map.empty`
    to create a map without knowing its internal representation.
    s-and-witch authored and GoPavel committed Oct 21, 2024
    Configuration menu
    Copy the full SHA
    174e877 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    92925ab View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    af994d6 View commit details
    Browse the repository at this point in the history
  7. Specify keys order in iterators

    s-and-witch authored and GoPavel committed Oct 21, 2024
    Configuration menu
    Copy the full SHA
    e040734 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    070673f View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    ef13759 View commit details
    Browse the repository at this point in the history
  10. PerisistentOrderedMap: fix docs

    * rename `rbMap` into `m` in signature for brevity & consistent language
    * rename `rbMap` into `map` in examples for brevity & encapsulation sake
    * rename `tree` into `map` in doc comments for the encapsulation sake
    GoPavel committed Oct 21, 2024
    Configuration menu
    Copy the full SHA
    d4b02eb View commit details
    Browse the repository at this point in the history

Commits on Oct 24, 2024

  1. Configuration menu
    Copy the full SHA
    26a33c1 View commit details
    Browse the repository at this point in the history