FSTTreeSortedDictionary.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /**
  2. * Implementation of an immutable SortedMap using a Left-leaning
  3. * Red-Black Tree, adapted from the implementation in Mugs
  4. * (http://mads379.github.com/mugs/) by Mads Hartmann Jensen
  5. * (mads379@gmail.com).
  6. *
  7. * Original paper on Left-leaning Red-Black Trees:
  8. * http://www.cs.princeton.edu/~rs/talks/LLRB/LLRB.pdf
  9. *
  10. * Invariant 1: No red node has a red child
  11. * Invariant 2: Every leaf path has the same number of black nodes
  12. * Invariant 3: Only the left child can be red (left leaning)
  13. */
  14. #import <Foundation/Foundation.h>
  15. #import "Firestore/third_party/Immutable/FSTImmutableSortedDictionary.h"
  16. #import "Firestore/third_party/Immutable/FSTLLRBNode.h"
  17. NS_ASSUME_NONNULL_BEGIN
  18. /**
  19. * FSTTreeSortedDictionary is a tree-based implementation of FSTImmutableSortedDictionary.
  20. * You should not use this class directly. You should use FSTImmutableSortedDictionary.
  21. */
  22. @interface FSTTreeSortedDictionary <KeyType, ValueType> :
  23. FSTImmutableSortedDictionary<KeyType, ValueType>
  24. @property(nonatomic, copy, readonly) NSComparator comparator;
  25. @property(nonatomic, strong, readonly) id<FSTLLRBNode> root;
  26. - (id)init __attribute__((unavailable("Use initWithComparator:withRoot: instead.")));
  27. - (instancetype)initWithComparator:(NSComparator)aComparator;
  28. - (instancetype)initWithComparator:(NSComparator)aComparator
  29. withRoot:(id<FSTLLRBNode>)aRoot NS_DESIGNATED_INITIALIZER;
  30. @end
  31. NS_ASSUME_NONNULL_END