FIndexedNode.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. #import <Foundation/Foundation.h>
  17. #import "FIndex.h"
  18. #import "FNamedNode.h"
  19. #import "FNode.h"
  20. /**
  21. * Represents a node together with an index. The index and node are updated in
  22. * unison. In the case where the index does not affect the ordering (i.e. the
  23. * ordering is identical to the key ordering) this class uses a fallback index
  24. * to save memory. Everything operating on the index must special case the
  25. * fallback index.
  26. */
  27. @interface FIndexedNode : NSObject
  28. @property(nonatomic, strong, readonly) id<FNode> node;
  29. + (FIndexedNode *)indexedNodeWithNode:(id<FNode>)node;
  30. + (FIndexedNode *)indexedNodeWithNode:(id<FNode>)node index:(id<FIndex>)index;
  31. - (BOOL)hasIndex:(id<FIndex>)index;
  32. - (FIndexedNode *)updateChild:(NSString *)key
  33. withNewChild:(id<FNode>)newChildNode;
  34. - (FIndexedNode *)updatePriority:(id<FNode>)priority;
  35. - (FNamedNode *)firstChild;
  36. - (FNamedNode *)lastChild;
  37. - (NSString *)predecessorForChildKey:(NSString *)childKey
  38. childNode:(id<FNode>)childNode
  39. index:(id<FIndex>)index;
  40. - (void)enumerateChildrenReverse:(BOOL)reverse
  41. usingBlock:(void (^)(NSString *key, id<FNode> node,
  42. BOOL *stop))block;
  43. - (NSEnumerator *)childEnumerator;
  44. @end