MyTree.h
上传用户:center1979
上传日期:2022-07-26
资源大小:50633k
文件大小:2k
源码类别:

OpenGL

开发平台:

Visual C++

  1. //
  2. //  MyTree.h
  3. //  celestia
  4. //
  5. //  Created by Bob Ippolito on Thu Jun 20 2002.
  6. //  Copyright (c) 2002 Chris Laurel. All rights reserved.
  7. //
  8. #import "NSArray_Extensions.h"
  9. @interface MyVector : NSMutableArray /*<NSCoding>*/ {
  10.     NSMutableArray *_array;
  11.     Class _myClass;
  12. }
  13. -(void)encodeWithCoder:(NSCoder*)coder;
  14. -(id)initWithCoder:(NSCoder*)coder;
  15. -(id)initWithClass:(Class)myClass;
  16. -(void)addObject:(id)obj;
  17. -(void)insertObject:(id)obj atIndex:(unsigned)idx;
  18. -(void)removeLastObject;
  19. -(void)removeObjectAtIndex:(unsigned)idx;
  20. -(void)replaceObjectAtIndex:(unsigned)idx withObject:(id)obj;
  21. -(unsigned)count;
  22. -(id)objectAtIndex:(unsigned)idx;
  23. @end
  24. @interface MyTree : NSObject <NSCoding> {
  25.     id <NSCoding> _nodeValue;
  26.     MyVector* _children;
  27.     MyTree* _parent;
  28. }
  29. -(void)encodeWithCoder:(NSCoder*)coder;
  30. -(id)initWithCoder:(NSCoder*)coder;
  31. // for initializing a tree root node
  32. -(id)init;
  33. // initializing a leaf node
  34. -(id)initWithNode:(id)obj parent:(MyTree*)parent;
  35. // initializing a branch node
  36. -(id)initWithNode:(id)obj parent:(MyTree*)parent children:(NSArray*)children;
  37. -(MyVector*)children;
  38. -(void)setNode:(id)obj;
  39. -(void)setChildren:(NSArray*)children;
  40. -(void)setParent:(MyTree*)parent;
  41. -(MyTree*)parent;
  42. -(id)nodeValue;
  43. -(BOOL)isLeaf;
  44. -(BOOL)isDescendantOfNode:(MyTree*)node;
  45. -(BOOL)isDescendantOfNodeInArray:(NSArray*)array;
  46. +(NSArray*)minimumNodeCoverFromNodesInArray:(NSArray*)allNodes;
  47. -(id)initWithDictionary:(NSDictionary*)dict parent:(MyTree*)parent;
  48. -(NSDictionary*)dictionary;
  49. -(NSDictionary*)recursiveDictionary;
  50. - (void)insertChild:(MyTree*)child atIndex:(int)index;
  51. - (void)insertChildren:(NSArray*)children atIndex:(int)index;
  52. - (void)removeChild:(MyTree*)child;
  53. - (void)removeFromParent;
  54. - (int)indexOfChild:(MyTree*)child;
  55. - (int)indexOfChildIdenticalTo:(MyTree*)child;
  56. - (int)numberOfChildren;
  57. - (MyTree*)firstChild;
  58. - (MyTree*)lastChild;
  59. - (MyTree*)childAtIndex:(int)index;
  60. @end