FTreeSortedDictionary.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * Copyright 2017 Google
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /**
  17. * @fileoverview Implementation of an immutable SortedMap using a Left-leaning
  18. * Red-Black Tree, adapted from the implementation in Mugs
  19. * (http://mads379.github.com/mugs/) by Mads Hartmann Jensen
  20. * (mads379@gmail.com).
  21. *
  22. * Original paper on Left-leaning Red-Black Trees:
  23. * http://www.cs.princeton.edu/~rs/talks/LLRB/LLRB.pdf
  24. *
  25. * Invariant 1: No red node has a red child
  26. * Invariant 2: Every leaf path has the same number of black nodes
  27. * Invariant 3: Only the left child can be red (left leaning)
  28. */
  29. #import <Foundation/Foundation.h>
  30. #import "FImmutableSortedDictionary.h"
  31. #import "FLLRBNode.h"
  32. @interface FTreeSortedDictionary : FImmutableSortedDictionary
  33. @property (nonatomic, copy, readonly) NSComparator comparator;
  34. @property (nonatomic, strong, readonly) id<FLLRBNode> root;
  35. - (id)initWithComparator:(NSComparator)aComparator;
  36. // Override methods to return subtype
  37. - (FTreeSortedDictionary *) insertKey:(id)aKey withValue:(id)aValue;
  38. - (FTreeSortedDictionary *) removeKey:(id)aKey;
  39. @end