FIndexedNode.h 1.7 KB

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