Skip to content
Browse files

Added SortedDictionary classes and tweaked them for ARC/Blocks compli…

…ancy.
  • Loading branch information...
1 parent 26cb85f commit 2fc148e86821765df076172ebfd0dee290bb946a Jim Dovey committed Jun 20, 2011
Showing with 10,335 additions and 34 deletions.
  1. +260 −0 AQAppStateMachine.xcodeproj/project.pbxproj
  2. +1 −2 AQAppStateMachine/AQAppStateMachine.m
  3. +12 −29 AQAppStateMachine/AQNotifyingBitfield.m
  4. +2 −2 AQAppStateMachine/AQStateMatchingDescriptor.m
  5. +5 −0 AQAppStateMachine/SortedDictionary/.svn/all-wcprops
  6. +34 −0 AQAppStateMachine/SortedDictionary/.svn/entries
  7. +1 −0 AQAppStateMachine/SortedDictionary/.svn/format
  8. +89 −0 AQAppStateMachine/SortedDictionary/Internal/.svn/all-wcprops
  9. +202 −0 AQAppStateMachine/SortedDictionary/Internal/.svn/entries
  10. +1 −0 AQAppStateMachine/SortedDictionary/Internal/.svn/format
  11. +9 −0 AQAppStateMachine/SortedDictionary/Internal/.svn/text-base/AvlTree+Private.h.svn-base
  12. +16 −0 AQAppStateMachine/SortedDictionary/Internal/.svn/text-base/AvlTree+Private.m.svn-base
  13. +36 −0 AQAppStateMachine/SortedDictionary/Internal/.svn/text-base/AvlTree.h.svn-base
  14. +273 −0 AQAppStateMachine/SortedDictionary/Internal/.svn/text-base/AvlTree.m.svn-base
  15. +12 −0 AQAppStateMachine/SortedDictionary/Internal/.svn/text-base/NSString+Base64.h.svn-base
  16. +61 −0 AQAppStateMachine/SortedDictionary/Internal/.svn/text-base/NSString+Base64.m.svn-base
  17. +11 −0 AQAppStateMachine/SortedDictionary/Internal/.svn/text-base/NSString+Indent.h.svn-base
  18. +27 −0 AQAppStateMachine/SortedDictionary/Internal/.svn/text-base/NSString+Indent.m.svn-base
  19. +45 −0 AQAppStateMachine/SortedDictionary/Internal/.svn/text-base/Node.h.svn-base
  20. +124 −0 AQAppStateMachine/SortedDictionary/Internal/.svn/text-base/Node.m.svn-base
  21. +11 −0 AQAppStateMachine/SortedDictionary/Internal/.svn/text-base/SortedDictionary+Private.h.svn-base
  22. +32 −0 AQAppStateMachine/SortedDictionary/Internal/.svn/text-base/SortedDictionary+Private.m.svn-base
  23. +2 −0 AQAppStateMachine/SortedDictionary/Internal/.svn/text-base/common.h.svn-base
  24. +5 −0 AQAppStateMachine/SortedDictionary/Internal/.svn/text-base/common.m.svn-base
  25. +9 −0 AQAppStateMachine/SortedDictionary/Internal/AvlTree+Private.h
  26. +16 −0 AQAppStateMachine/SortedDictionary/Internal/AvlTree+Private.m
  27. +36 −0 AQAppStateMachine/SortedDictionary/Internal/AvlTree.h
  28. +273 −0 AQAppStateMachine/SortedDictionary/Internal/AvlTree.m
  29. +53 −0 AQAppStateMachine/SortedDictionary/Internal/Enumerators/.svn/all-wcprops
  30. +124 −0 AQAppStateMachine/SortedDictionary/Internal/Enumerators/.svn/entries
  31. +1 −0 AQAppStateMachine/SortedDictionary/Internal/Enumerators/.svn/format
  32. +9 −0 ...teMachine/SortedDictionary/Internal/Enumerators/.svn/text-base/EntryEnumerator+Private.h.svn-base
  33. +28 −0 ...teMachine/SortedDictionary/Internal/Enumerators/.svn/text-base/EntryEnumerator+Private.m.svn-base
  34. +17 −0 AQAppStateMachine/SortedDictionary/Internal/Enumerators/.svn/text-base/EntryEnumerator.h.svn-base
  35. +48 −0 AQAppStateMachine/SortedDictionary/Internal/Enumerators/.svn/text-base/EntryEnumerator.m.svn-base
  36. +16 −0 AQAppStateMachine/SortedDictionary/Internal/Enumerators/.svn/text-base/KeyEnumerator.h.svn-base
  37. +39 −0 AQAppStateMachine/SortedDictionary/Internal/Enumerators/.svn/text-base/KeyEnumerator.m.svn-base
  38. +16 −0 AQAppStateMachine/SortedDictionary/Internal/Enumerators/.svn/text-base/ObjectEnumerator.h.svn-base
  39. +39 −0 AQAppStateMachine/SortedDictionary/Internal/Enumerators/.svn/text-base/ObjectEnumerator.m.svn-base
  40. +9 −0 AQAppStateMachine/SortedDictionary/Internal/Enumerators/EntryEnumerator+Private.h
  41. +28 −0 AQAppStateMachine/SortedDictionary/Internal/Enumerators/EntryEnumerator+Private.m
  42. +17 −0 AQAppStateMachine/SortedDictionary/Internal/Enumerators/EntryEnumerator.h
  43. +48 −0 AQAppStateMachine/SortedDictionary/Internal/Enumerators/EntryEnumerator.m
  44. +16 −0 AQAppStateMachine/SortedDictionary/Internal/Enumerators/KeyEnumerator.h
  45. +39 −0 AQAppStateMachine/SortedDictionary/Internal/Enumerators/KeyEnumerator.m
  46. +16 −0 AQAppStateMachine/SortedDictionary/Internal/Enumerators/ObjectEnumerator.h
  47. +39 −0 AQAppStateMachine/SortedDictionary/Internal/Enumerators/ObjectEnumerator.m
  48. +12 −0 AQAppStateMachine/SortedDictionary/Internal/NSString+Base64.h
  49. +61 −0 AQAppStateMachine/SortedDictionary/Internal/NSString+Base64.m
  50. +11 −0 AQAppStateMachine/SortedDictionary/Internal/NSString+Indent.h
  51. +27 −0 AQAppStateMachine/SortedDictionary/Internal/NSString+Indent.m
  52. +45 −0 AQAppStateMachine/SortedDictionary/Internal/Node.h
  53. +124 −0 AQAppStateMachine/SortedDictionary/Internal/Node.m
  54. +29 −0 AQAppStateMachine/SortedDictionary/Internal/Serialization/.svn/all-wcprops
  55. +76 −0 AQAppStateMachine/SortedDictionary/Internal/Serialization/.svn/entries
  56. +1 −0 AQAppStateMachine/SortedDictionary/Internal/Serialization/.svn/format
  57. +26 −0 ...StateMachine/SortedDictionary/Internal/Serialization/.svn/text-base/PropertyListReader.h.svn-base
  58. +213 −0 ...StateMachine/SortedDictionary/Internal/Serialization/.svn/text-base/PropertyListReader.m.svn-base
  59. +23 −0 ...StateMachine/SortedDictionary/Internal/Serialization/.svn/text-base/PropertyListWriter.h.svn-base
  60. +206 −0 ...StateMachine/SortedDictionary/Internal/Serialization/.svn/text-base/PropertyListWriter.m.svn-base
  61. +26 −0 AQAppStateMachine/SortedDictionary/Internal/Serialization/PropertyListReader.h
  62. +212 −0 AQAppStateMachine/SortedDictionary/Internal/Serialization/PropertyListReader.m
  63. +23 −0 AQAppStateMachine/SortedDictionary/Internal/Serialization/PropertyListWriter.h
  64. +206 −0 AQAppStateMachine/SortedDictionary/Internal/Serialization/PropertyListWriter.m
  65. +11 −0 AQAppStateMachine/SortedDictionary/Internal/SortedDictionary+Private.h
  66. +32 −0 AQAppStateMachine/SortedDictionary/Internal/SortedDictionary+Private.m
  67. +2 −0 AQAppStateMachine/SortedDictionary/Internal/common.h
  68. +5 −0 AQAppStateMachine/SortedDictionary/Internal/common.m
  69. +35 −0 AQAppStateMachine/SortedDictionary/Public/.svn/all-wcprops
  70. +112 −0 AQAppStateMachine/SortedDictionary/Public/.svn/entries
  71. +1 −0 AQAppStateMachine/SortedDictionary/Public/.svn/format
  72. +35 −0 AQAppStateMachine/SortedDictionary/Public/.svn/text-base/MutableSortedDictionary.h.svn-base
  73. +216 −0 AQAppStateMachine/SortedDictionary/Public/.svn/text-base/MutableSortedDictionary.m.svn-base
  74. +133 −0 AQAppStateMachine/SortedDictionary/Public/.svn/text-base/SortedDictionary.h.svn-base
  75. +1,305 −0 AQAppStateMachine/SortedDictionary/Public/.svn/text-base/SortedDictionary.m.svn-base
  76. +6 −0 AQAppStateMachine/SortedDictionary/Public/.svn/text-base/SortedDictionaryEntry.h.svn-base
  77. +73 −0 AQAppStateMachine/SortedDictionary/Public/AQAdditions.m
  78. +35 −0 AQAppStateMachine/SortedDictionary/Public/MutableSortedDictionary.h
  79. +216 −0 AQAppStateMachine/SortedDictionary/Public/MutableSortedDictionary.m
  80. +145 −0 AQAppStateMachine/SortedDictionary/Public/SortedDictionary.h
  81. +1,305 −0 AQAppStateMachine/SortedDictionary/Public/SortedDictionary.m
  82. +6 −0 AQAppStateMachine/SortedDictionary/Public/SortedDictionaryEntry.h
  83. +1 −1 AQAppStateMachineTests/AQAppStateMachineTests.m
  84. +107 −0 AQAppStateMachineTests/SortedDictionary/.svn/all-wcprops
  85. +232 −0 AQAppStateMachineTests/SortedDictionary/.svn/entries
  86. +1 −0 AQAppStateMachineTests/SortedDictionary/.svn/format
  87. +7 −0 ...pStateMachineTests/SortedDictionary/.svn/text-base/MutableSortedDictionaryContentTests.h.svn-base
  88. +280 −0 ...pStateMachineTests/SortedDictionary/.svn/text-base/MutableSortedDictionaryContentTests.m.svn-base
  89. +7 −0 AQAppStateMachineTests/SortedDictionary/.svn/text-base/NSStringExtensionsTests.h.svn-base
  90. +24 −0 AQAppStateMachineTests/SortedDictionary/.svn/text-base/NSStringExtensionsTests.m.svn-base
  91. +9 −0 AQAppStateMachineTests/SortedDictionary/.svn/text-base/SortedDictionary+Test.h.svn-base
  92. +29 −0 AQAppStateMachineTests/SortedDictionary/.svn/text-base/SortedDictionary+Test.m.svn-base
  93. +10 −0 AQAppStateMachineTests/SortedDictionary/.svn/text-base/SortedDictionaryContentTests.h.svn-base
  94. +467 −0 AQAppStateMachineTests/SortedDictionary/.svn/text-base/SortedDictionaryContentTests.m.svn-base
  95. +7 −0 AQAppStateMachineTests/SortedDictionary/.svn/text-base/SortedDictionaryCreationTests.h.svn-base
  96. +144 −0 AQAppStateMachineTests/SortedDictionary/.svn/text-base/SortedDictionaryCreationTests.m.svn-base
  97. +8 −0 ...pStateMachineTests/SortedDictionary/.svn/text-base/SortedDictionaryInitializationTests.h.svn-base
  98. +179 −0 ...pStateMachineTests/SortedDictionary/.svn/text-base/SortedDictionaryInitializationTests.m.svn-base
  99. +10 −0 AQAppStateMachineTests/SortedDictionary/.svn/text-base/SortedDictionaryProtocolTests.h.svn-base
  100. +87 −0 AQAppStateMachineTests/SortedDictionary/.svn/text-base/SortedDictionaryProtocolTests.m.svn-base
  101. +7 −0 AQAppStateMachineTests/SortedDictionary/.svn/text-base/SortedDictionarySerializationTests.h.svn-base
  102. +85 −0 AQAppStateMachineTests/SortedDictionary/.svn/text-base/SortedDictionarySerializationTests.m.svn-base
  103. +5 −0 AQAppStateMachineTests/SortedDictionary/.svn/text-base/test.plist.svn-base
  104. +7 −0 AQAppStateMachineTests/SortedDictionary/MutableSortedDictionaryContentTests.h
  105. +280 −0 AQAppStateMachineTests/SortedDictionary/MutableSortedDictionaryContentTests.m
  106. +7 −0 AQAppStateMachineTests/SortedDictionary/NSStringExtensionsTests.h
  107. +24 −0 AQAppStateMachineTests/SortedDictionary/NSStringExtensionsTests.m
  108. +9 −0 AQAppStateMachineTests/SortedDictionary/SortedDictionary+Test.h
  109. +29 −0 AQAppStateMachineTests/SortedDictionary/SortedDictionary+Test.m
  110. +10 −0 AQAppStateMachineTests/SortedDictionary/SortedDictionaryContentTests.h
  111. +524 −0 AQAppStateMachineTests/SortedDictionary/SortedDictionaryContentTests.m
  112. +7 −0 AQAppStateMachineTests/SortedDictionary/SortedDictionaryCreationTests.h
  113. +150 −0 AQAppStateMachineTests/SortedDictionary/SortedDictionaryCreationTests.m
  114. +8 −0 AQAppStateMachineTests/SortedDictionary/SortedDictionaryInitializationTests.h
  115. +179 −0 AQAppStateMachineTests/SortedDictionary/SortedDictionaryInitializationTests.m
  116. +10 −0 AQAppStateMachineTests/SortedDictionary/SortedDictionaryProtocolTests.h
  117. +87 −0 AQAppStateMachineTests/SortedDictionary/SortedDictionaryProtocolTests.m
  118. +7 −0 AQAppStateMachineTests/SortedDictionary/SortedDictionarySerializationTests.h
  119. +85 −0 AQAppStateMachineTests/SortedDictionary/SortedDictionarySerializationTests.m
  120. +5 −0 AQAppStateMachineTests/SortedDictionary/test.plist
View
260 AQAppStateMachine.xcodeproj/project.pbxproj
@@ -29,6 +29,63 @@
3866939A13ABC70300268560 /* AQStateMatchingDescriptor.h in Headers */ = {isa = PBXBuildFile; fileRef = 3866939813ABC70200268560 /* AQStateMatchingDescriptor.h */; };
3866939B13ABC70300268560 /* AQStateMatchingDescriptor.m in Sources */ = {isa = PBXBuildFile; fileRef = 3866939913ABC70300268560 /* AQStateMatchingDescriptor.m */; };
3866939C13ABC70300268560 /* AQStateMatchingDescriptor.m in Sources */ = {isa = PBXBuildFile; fileRef = 3866939913ABC70300268560 /* AQStateMatchingDescriptor.m */; };
+ 3866940113AF8A1500268560 /* MutableSortedDictionaryContentTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 386693F113AF8A1500268560 /* MutableSortedDictionaryContentTests.m */; };
+ 3866940213AF8A1500268560 /* NSStringExtensionsTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 386693F313AF8A1500268560 /* NSStringExtensionsTests.m */; };
+ 3866940313AF8A1500268560 /* SortedDictionary+Test.m in Sources */ = {isa = PBXBuildFile; fileRef = 386693F513AF8A1500268560 /* SortedDictionary+Test.m */; };
+ 3866940413AF8A1500268560 /* SortedDictionaryContentTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 386693F713AF8A1500268560 /* SortedDictionaryContentTests.m */; };
+ 3866940513AF8A1500268560 /* SortedDictionaryCreationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 386693F913AF8A1500268560 /* SortedDictionaryCreationTests.m */; };
+ 3866940613AF8A1500268560 /* SortedDictionaryInitializationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 386693FB13AF8A1500268560 /* SortedDictionaryInitializationTests.m */; };
+ 3866940713AF8A1500268560 /* SortedDictionaryProtocolTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 386693FD13AF8A1500268560 /* SortedDictionaryProtocolTests.m */; };
+ 3866940813AF8A1500268560 /* SortedDictionarySerializationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 386693FF13AF8A1500268560 /* SortedDictionarySerializationTests.m */; };
+ 3866940913AF8A1500268560 /* test.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3866940013AF8A1500268560 /* test.plist */; };
+ 3866942E13AF8A1F00268560 /* AvlTree+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 3866940C13AF8A1F00268560 /* AvlTree+Private.h */; };
+ 3866942F13AF8A1F00268560 /* AvlTree+Private.m in Sources */ = {isa = PBXBuildFile; fileRef = 3866940D13AF8A1F00268560 /* AvlTree+Private.m */; };
+ 3866943013AF8A1F00268560 /* AvlTree+Private.m in Sources */ = {isa = PBXBuildFile; fileRef = 3866940D13AF8A1F00268560 /* AvlTree+Private.m */; };
+ 3866943113AF8A1F00268560 /* AvlTree.h in Headers */ = {isa = PBXBuildFile; fileRef = 3866940E13AF8A1F00268560 /* AvlTree.h */; };
+ 3866943213AF8A1F00268560 /* AvlTree.m in Sources */ = {isa = PBXBuildFile; fileRef = 3866940F13AF8A1F00268560 /* AvlTree.m */; };
+ 3866943313AF8A1F00268560 /* AvlTree.m in Sources */ = {isa = PBXBuildFile; fileRef = 3866940F13AF8A1F00268560 /* AvlTree.m */; };
+ 3866943413AF8A1F00268560 /* common.h in Headers */ = {isa = PBXBuildFile; fileRef = 3866941013AF8A1F00268560 /* common.h */; };
+ 3866943513AF8A1F00268560 /* common.m in Sources */ = {isa = PBXBuildFile; fileRef = 3866941113AF8A1F00268560 /* common.m */; };
+ 3866943613AF8A1F00268560 /* common.m in Sources */ = {isa = PBXBuildFile; fileRef = 3866941113AF8A1F00268560 /* common.m */; };
+ 3866943713AF8A1F00268560 /* EntryEnumerator+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 3866941313AF8A1F00268560 /* EntryEnumerator+Private.h */; };
+ 3866943813AF8A1F00268560 /* EntryEnumerator+Private.m in Sources */ = {isa = PBXBuildFile; fileRef = 3866941413AF8A1F00268560 /* EntryEnumerator+Private.m */; };
+ 3866943913AF8A1F00268560 /* EntryEnumerator+Private.m in Sources */ = {isa = PBXBuildFile; fileRef = 3866941413AF8A1F00268560 /* EntryEnumerator+Private.m */; };
+ 3866943A13AF8A1F00268560 /* EntryEnumerator.h in Headers */ = {isa = PBXBuildFile; fileRef = 3866941513AF8A1F00268560 /* EntryEnumerator.h */; };
+ 3866943B13AF8A1F00268560 /* EntryEnumerator.m in Sources */ = {isa = PBXBuildFile; fileRef = 3866941613AF8A1F00268560 /* EntryEnumerator.m */; };
+ 3866943C13AF8A1F00268560 /* EntryEnumerator.m in Sources */ = {isa = PBXBuildFile; fileRef = 3866941613AF8A1F00268560 /* EntryEnumerator.m */; };
+ 3866943D13AF8A1F00268560 /* KeyEnumerator.h in Headers */ = {isa = PBXBuildFile; fileRef = 3866941713AF8A1F00268560 /* KeyEnumerator.h */; };
+ 3866943E13AF8A1F00268560 /* KeyEnumerator.m in Sources */ = {isa = PBXBuildFile; fileRef = 3866941813AF8A1F00268560 /* KeyEnumerator.m */; };
+ 3866943F13AF8A1F00268560 /* KeyEnumerator.m in Sources */ = {isa = PBXBuildFile; fileRef = 3866941813AF8A1F00268560 /* KeyEnumerator.m */; };
+ 3866944013AF8A1F00268560 /* ObjectEnumerator.h in Headers */ = {isa = PBXBuildFile; fileRef = 3866941913AF8A1F00268560 /* ObjectEnumerator.h */; };
+ 3866944113AF8A1F00268560 /* ObjectEnumerator.m in Sources */ = {isa = PBXBuildFile; fileRef = 3866941A13AF8A1F00268560 /* ObjectEnumerator.m */; };
+ 3866944213AF8A1F00268560 /* ObjectEnumerator.m in Sources */ = {isa = PBXBuildFile; fileRef = 3866941A13AF8A1F00268560 /* ObjectEnumerator.m */; };
+ 3866944313AF8A1F00268560 /* Node.h in Headers */ = {isa = PBXBuildFile; fileRef = 3866941B13AF8A1F00268560 /* Node.h */; };
+ 3866944413AF8A1F00268560 /* Node.m in Sources */ = {isa = PBXBuildFile; fileRef = 3866941C13AF8A1F00268560 /* Node.m */; };
+ 3866944513AF8A1F00268560 /* Node.m in Sources */ = {isa = PBXBuildFile; fileRef = 3866941C13AF8A1F00268560 /* Node.m */; };
+ 3866944613AF8A1F00268560 /* NSString+Base64.h in Headers */ = {isa = PBXBuildFile; fileRef = 3866941D13AF8A1F00268560 /* NSString+Base64.h */; };
+ 3866944713AF8A1F00268560 /* NSString+Base64.m in Sources */ = {isa = PBXBuildFile; fileRef = 3866941E13AF8A1F00268560 /* NSString+Base64.m */; };
+ 3866944813AF8A1F00268560 /* NSString+Base64.m in Sources */ = {isa = PBXBuildFile; fileRef = 3866941E13AF8A1F00268560 /* NSString+Base64.m */; };
+ 3866944913AF8A1F00268560 /* NSString+Indent.h in Headers */ = {isa = PBXBuildFile; fileRef = 3866941F13AF8A1F00268560 /* NSString+Indent.h */; };
+ 3866944A13AF8A1F00268560 /* NSString+Indent.m in Sources */ = {isa = PBXBuildFile; fileRef = 3866942013AF8A1F00268560 /* NSString+Indent.m */; };
+ 3866944B13AF8A1F00268560 /* NSString+Indent.m in Sources */ = {isa = PBXBuildFile; fileRef = 3866942013AF8A1F00268560 /* NSString+Indent.m */; };
+ 3866944C13AF8A1F00268560 /* PropertyListReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 3866942213AF8A1F00268560 /* PropertyListReader.h */; };
+ 3866944D13AF8A1F00268560 /* PropertyListReader.m in Sources */ = {isa = PBXBuildFile; fileRef = 3866942313AF8A1F00268560 /* PropertyListReader.m */; };
+ 3866944E13AF8A1F00268560 /* PropertyListReader.m in Sources */ = {isa = PBXBuildFile; fileRef = 3866942313AF8A1F00268560 /* PropertyListReader.m */; };
+ 3866944F13AF8A1F00268560 /* PropertyListWriter.h in Headers */ = {isa = PBXBuildFile; fileRef = 3866942413AF8A1F00268560 /* PropertyListWriter.h */; };
+ 3866945013AF8A1F00268560 /* PropertyListWriter.m in Sources */ = {isa = PBXBuildFile; fileRef = 3866942513AF8A1F00268560 /* PropertyListWriter.m */; };
+ 3866945113AF8A1F00268560 /* PropertyListWriter.m in Sources */ = {isa = PBXBuildFile; fileRef = 3866942513AF8A1F00268560 /* PropertyListWriter.m */; };
+ 3866945213AF8A1F00268560 /* SortedDictionary+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 3866942613AF8A1F00268560 /* SortedDictionary+Private.h */; };
+ 3866945313AF8A1F00268560 /* SortedDictionary+Private.m in Sources */ = {isa = PBXBuildFile; fileRef = 3866942713AF8A1F00268560 /* SortedDictionary+Private.m */; };
+ 3866945413AF8A1F00268560 /* SortedDictionary+Private.m in Sources */ = {isa = PBXBuildFile; fileRef = 3866942713AF8A1F00268560 /* SortedDictionary+Private.m */; };
+ 3866945513AF8A1F00268560 /* MutableSortedDictionary.h in Headers */ = {isa = PBXBuildFile; fileRef = 3866942913AF8A1F00268560 /* MutableSortedDictionary.h */; };
+ 3866945613AF8A1F00268560 /* MutableSortedDictionary.m in Sources */ = {isa = PBXBuildFile; fileRef = 3866942A13AF8A1F00268560 /* MutableSortedDictionary.m */; };
+ 3866945713AF8A1F00268560 /* MutableSortedDictionary.m in Sources */ = {isa = PBXBuildFile; fileRef = 3866942A13AF8A1F00268560 /* MutableSortedDictionary.m */; };
+ 3866945813AF8A1F00268560 /* SortedDictionary.h in Headers */ = {isa = PBXBuildFile; fileRef = 3866942B13AF8A1F00268560 /* SortedDictionary.h */; };
+ 3866945913AF8A1F00268560 /* SortedDictionary.m in Sources */ = {isa = PBXBuildFile; fileRef = 3866942C13AF8A1F00268560 /* SortedDictionary.m */; };
+ 3866945A13AF8A1F00268560 /* SortedDictionary.m in Sources */ = {isa = PBXBuildFile; fileRef = 3866942C13AF8A1F00268560 /* SortedDictionary.m */; };
+ 3866945B13AF8A1F00268560 /* SortedDictionaryEntry.h in Headers */ = {isa = PBXBuildFile; fileRef = 3866942D13AF8A1F00268560 /* SortedDictionaryEntry.h */; };
+ 3866945F13AF8AF300268560 /* AQAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 3866945D13AF8AF300268560 /* AQAdditions.m */; };
+ 3866946013AFB77500268560 /* AQAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 3866945D13AF8AF300268560 /* AQAdditions.m */; };
38AC30BC13AA3D5C00AB071C /* AQBitfieldPredicates.h in Headers */ = {isa = PBXBuildFile; fileRef = 38AC30BA13AA3D5C00AB071C /* AQBitfieldPredicates.h */; };
38AC30BD13AA3D5C00AB071C /* AQBitfieldPredicates.m in Sources */ = {isa = PBXBuildFile; fileRef = 38AC30BB13AA3D5C00AB071C /* AQBitfieldPredicates.m */; };
38AC30BE13AA3D5C00AB071C /* AQBitfieldPredicates.m in Sources */ = {isa = PBXBuildFile; fileRef = 38AC30BB13AA3D5C00AB071C /* AQBitfieldPredicates.m */; };
@@ -65,6 +122,55 @@
3866939413AAA0C600268560 /* AQAppStateMachine.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AQAppStateMachine.m; sourceTree = "<group>"; };
3866939813ABC70200268560 /* AQStateMatchingDescriptor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AQStateMatchingDescriptor.h; sourceTree = "<group>"; };
3866939913ABC70300268560 /* AQStateMatchingDescriptor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AQStateMatchingDescriptor.m; sourceTree = "<group>"; };
+ 386693F013AF8A1500268560 /* MutableSortedDictionaryContentTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MutableSortedDictionaryContentTests.h; sourceTree = "<group>"; };
+ 386693F113AF8A1500268560 /* MutableSortedDictionaryContentTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MutableSortedDictionaryContentTests.m; sourceTree = "<group>"; };
+ 386693F213AF8A1500268560 /* NSStringExtensionsTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSStringExtensionsTests.h; sourceTree = "<group>"; };
+ 386693F313AF8A1500268560 /* NSStringExtensionsTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NSStringExtensionsTests.m; sourceTree = "<group>"; };
+ 386693F413AF8A1500268560 /* SortedDictionary+Test.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "SortedDictionary+Test.h"; sourceTree = "<group>"; };
+ 386693F513AF8A1500268560 /* SortedDictionary+Test.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "SortedDictionary+Test.m"; sourceTree = "<group>"; };
+ 386693F613AF8A1500268560 /* SortedDictionaryContentTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SortedDictionaryContentTests.h; sourceTree = "<group>"; };
+ 386693F713AF8A1500268560 /* SortedDictionaryContentTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SortedDictionaryContentTests.m; sourceTree = "<group>"; };
+ 386693F813AF8A1500268560 /* SortedDictionaryCreationTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SortedDictionaryCreationTests.h; sourceTree = "<group>"; };
+ 386693F913AF8A1500268560 /* SortedDictionaryCreationTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SortedDictionaryCreationTests.m; sourceTree = "<group>"; };
+ 386693FA13AF8A1500268560 /* SortedDictionaryInitializationTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SortedDictionaryInitializationTests.h; sourceTree = "<group>"; };
+ 386693FB13AF8A1500268560 /* SortedDictionaryInitializationTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SortedDictionaryInitializationTests.m; sourceTree = "<group>"; };
+ 386693FC13AF8A1500268560 /* SortedDictionaryProtocolTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SortedDictionaryProtocolTests.h; sourceTree = "<group>"; };
+ 386693FD13AF8A1500268560 /* SortedDictionaryProtocolTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SortedDictionaryProtocolTests.m; sourceTree = "<group>"; };
+ 386693FE13AF8A1500268560 /* SortedDictionarySerializationTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SortedDictionarySerializationTests.h; sourceTree = "<group>"; };
+ 386693FF13AF8A1500268560 /* SortedDictionarySerializationTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SortedDictionarySerializationTests.m; sourceTree = "<group>"; };
+ 3866940013AF8A1500268560 /* test.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = test.plist; sourceTree = "<group>"; };
+ 3866940C13AF8A1F00268560 /* AvlTree+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "AvlTree+Private.h"; sourceTree = "<group>"; };
+ 3866940D13AF8A1F00268560 /* AvlTree+Private.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "AvlTree+Private.m"; sourceTree = "<group>"; };
+ 3866940E13AF8A1F00268560 /* AvlTree.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AvlTree.h; sourceTree = "<group>"; };
+ 3866940F13AF8A1F00268560 /* AvlTree.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AvlTree.m; sourceTree = "<group>"; };
+ 3866941013AF8A1F00268560 /* common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = common.h; sourceTree = "<group>"; };
+ 3866941113AF8A1F00268560 /* common.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = common.m; sourceTree = "<group>"; };
+ 3866941313AF8A1F00268560 /* EntryEnumerator+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "EntryEnumerator+Private.h"; sourceTree = "<group>"; };
+ 3866941413AF8A1F00268560 /* EntryEnumerator+Private.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "EntryEnumerator+Private.m"; sourceTree = "<group>"; };
+ 3866941513AF8A1F00268560 /* EntryEnumerator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EntryEnumerator.h; sourceTree = "<group>"; };
+ 3866941613AF8A1F00268560 /* EntryEnumerator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EntryEnumerator.m; sourceTree = "<group>"; };
+ 3866941713AF8A1F00268560 /* KeyEnumerator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KeyEnumerator.h; sourceTree = "<group>"; };
+ 3866941813AF8A1F00268560 /* KeyEnumerator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KeyEnumerator.m; sourceTree = "<group>"; };
+ 3866941913AF8A1F00268560 /* ObjectEnumerator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ObjectEnumerator.h; sourceTree = "<group>"; };
+ 3866941A13AF8A1F00268560 /* ObjectEnumerator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ObjectEnumerator.m; sourceTree = "<group>"; };
+ 3866941B13AF8A1F00268560 /* Node.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Node.h; sourceTree = "<group>"; };
+ 3866941C13AF8A1F00268560 /* Node.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Node.m; sourceTree = "<group>"; };
+ 3866941D13AF8A1F00268560 /* NSString+Base64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+Base64.h"; sourceTree = "<group>"; };
+ 3866941E13AF8A1F00268560 /* NSString+Base64.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+Base64.m"; sourceTree = "<group>"; };
+ 3866941F13AF8A1F00268560 /* NSString+Indent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+Indent.h"; sourceTree = "<group>"; };
+ 3866942013AF8A1F00268560 /* NSString+Indent.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+Indent.m"; sourceTree = "<group>"; };
+ 3866942213AF8A1F00268560 /* PropertyListReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PropertyListReader.h; sourceTree = "<group>"; };
+ 3866942313AF8A1F00268560 /* PropertyListReader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PropertyListReader.m; sourceTree = "<group>"; };
+ 3866942413AF8A1F00268560 /* PropertyListWriter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PropertyListWriter.h; sourceTree = "<group>"; };
+ 3866942513AF8A1F00268560 /* PropertyListWriter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PropertyListWriter.m; sourceTree = "<group>"; };
+ 3866942613AF8A1F00268560 /* SortedDictionary+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "SortedDictionary+Private.h"; sourceTree = "<group>"; };
+ 3866942713AF8A1F00268560 /* SortedDictionary+Private.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "SortedDictionary+Private.m"; sourceTree = "<group>"; };
+ 3866942913AF8A1F00268560 /* MutableSortedDictionary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MutableSortedDictionary.h; sourceTree = "<group>"; };
+ 3866942A13AF8A1F00268560 /* MutableSortedDictionary.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MutableSortedDictionary.m; sourceTree = "<group>"; };
+ 3866942B13AF8A1F00268560 /* SortedDictionary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SortedDictionary.h; sourceTree = "<group>"; };
+ 3866942C13AF8A1F00268560 /* SortedDictionary.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SortedDictionary.m; sourceTree = "<group>"; };
+ 3866942D13AF8A1F00268560 /* SortedDictionaryEntry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SortedDictionaryEntry.h; sourceTree = "<group>"; };
+ 3866945D13AF8AF300268560 /* AQAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AQAdditions.m; sourceTree = "<group>"; };
38AC30BA13AA3D5C00AB071C /* AQBitfieldPredicates.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AQBitfieldPredicates.h; sourceTree = "<group>"; };
38AC30BB13AA3D5C00AB071C /* AQBitfieldPredicates.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AQBitfieldPredicates.m; sourceTree = "<group>"; };
/* End PBXFileReference section */
@@ -137,6 +243,7 @@
3866939413AAA0C600268560 /* AQAppStateMachine.m */,
3866939813ABC70200268560 /* AQStateMatchingDescriptor.h */,
3866939913ABC70300268560 /* AQStateMatchingDescriptor.m */,
+ 3866940A13AF8A1F00268560 /* SortedDictionary */,
38431B5A13A7C26800178A7E /* Supporting Files */,
);
path = AQAppStateMachine;
@@ -155,6 +262,7 @@
children = (
38431B7213A7C26900178A7E /* AQAppStateMachineTests.h */,
38431B7413A7C26900178A7E /* AQAppStateMachineTests.m */,
+ 386693EF13AF8A1500268560 /* SortedDictionary */,
38431B6D13A7C26900178A7E /* Supporting Files */,
);
path = AQAppStateMachineTests;
@@ -169,6 +277,101 @@
name = "Supporting Files";
sourceTree = "<group>";
};
+ 386693EF13AF8A1500268560 /* SortedDictionary */ = {
+ isa = PBXGroup;
+ children = (
+ 386693F013AF8A1500268560 /* MutableSortedDictionaryContentTests.h */,
+ 386693F113AF8A1500268560 /* MutableSortedDictionaryContentTests.m */,
+ 386693F213AF8A1500268560 /* NSStringExtensionsTests.h */,
+ 386693F313AF8A1500268560 /* NSStringExtensionsTests.m */,
+ 386693F413AF8A1500268560 /* SortedDictionary+Test.h */,
+ 386693F513AF8A1500268560 /* SortedDictionary+Test.m */,
+ 386693F613AF8A1500268560 /* SortedDictionaryContentTests.h */,
+ 386693F713AF8A1500268560 /* SortedDictionaryContentTests.m */,
+ 386693F813AF8A1500268560 /* SortedDictionaryCreationTests.h */,
+ 386693F913AF8A1500268560 /* SortedDictionaryCreationTests.m */,
+ 386693FA13AF8A1500268560 /* SortedDictionaryInitializationTests.h */,
+ 386693FB13AF8A1500268560 /* SortedDictionaryInitializationTests.m */,
+ 386693FC13AF8A1500268560 /* SortedDictionaryProtocolTests.h */,
+ 386693FD13AF8A1500268560 /* SortedDictionaryProtocolTests.m */,
+ 386693FE13AF8A1500268560 /* SortedDictionarySerializationTests.h */,
+ 386693FF13AF8A1500268560 /* SortedDictionarySerializationTests.m */,
+ 3866940013AF8A1500268560 /* test.plist */,
+ );
+ path = SortedDictionary;
+ sourceTree = "<group>";
+ };
+ 3866940A13AF8A1F00268560 /* SortedDictionary */ = {
+ isa = PBXGroup;
+ children = (
+ 3866940B13AF8A1F00268560 /* Internal */,
+ 3866942813AF8A1F00268560 /* Public */,
+ );
+ path = SortedDictionary;
+ sourceTree = "<group>";
+ };
+ 3866940B13AF8A1F00268560 /* Internal */ = {
+ isa = PBXGroup;
+ children = (
+ 3866940C13AF8A1F00268560 /* AvlTree+Private.h */,
+ 3866940D13AF8A1F00268560 /* AvlTree+Private.m */,
+ 3866940E13AF8A1F00268560 /* AvlTree.h */,
+ 3866940F13AF8A1F00268560 /* AvlTree.m */,
+ 3866941013AF8A1F00268560 /* common.h */,
+ 3866941113AF8A1F00268560 /* common.m */,
+ 3866941213AF8A1F00268560 /* Enumerators */,
+ 3866941B13AF8A1F00268560 /* Node.h */,
+ 3866941C13AF8A1F00268560 /* Node.m */,
+ 3866941D13AF8A1F00268560 /* NSString+Base64.h */,
+ 3866941E13AF8A1F00268560 /* NSString+Base64.m */,
+ 3866941F13AF8A1F00268560 /* NSString+Indent.h */,
+ 3866942013AF8A1F00268560 /* NSString+Indent.m */,
+ 3866942113AF8A1F00268560 /* Serialization */,
+ 3866942613AF8A1F00268560 /* SortedDictionary+Private.h */,
+ 3866942713AF8A1F00268560 /* SortedDictionary+Private.m */,
+ );
+ path = Internal;
+ sourceTree = "<group>";
+ };
+ 3866941213AF8A1F00268560 /* Enumerators */ = {
+ isa = PBXGroup;
+ children = (
+ 3866941313AF8A1F00268560 /* EntryEnumerator+Private.h */,
+ 3866941413AF8A1F00268560 /* EntryEnumerator+Private.m */,
+ 3866941513AF8A1F00268560 /* EntryEnumerator.h */,
+ 3866941613AF8A1F00268560 /* EntryEnumerator.m */,
+ 3866941713AF8A1F00268560 /* KeyEnumerator.h */,
+ 3866941813AF8A1F00268560 /* KeyEnumerator.m */,
+ 3866941913AF8A1F00268560 /* ObjectEnumerator.h */,
+ 3866941A13AF8A1F00268560 /* ObjectEnumerator.m */,
+ );
+ path = Enumerators;
+ sourceTree = "<group>";
+ };
+ 3866942113AF8A1F00268560 /* Serialization */ = {
+ isa = PBXGroup;
+ children = (
+ 3866942213AF8A1F00268560 /* PropertyListReader.h */,
+ 3866942313AF8A1F00268560 /* PropertyListReader.m */,
+ 3866942413AF8A1F00268560 /* PropertyListWriter.h */,
+ 3866942513AF8A1F00268560 /* PropertyListWriter.m */,
+ );
+ path = Serialization;
+ sourceTree = "<group>";
+ };
+ 3866942813AF8A1F00268560 /* Public */ = {
+ isa = PBXGroup;
+ children = (
+ 3866942913AF8A1F00268560 /* MutableSortedDictionary.h */,
+ 3866942A13AF8A1F00268560 /* MutableSortedDictionary.m */,
+ 3866942B13AF8A1F00268560 /* SortedDictionary.h */,
+ 3866942C13AF8A1F00268560 /* SortedDictionary.m */,
+ 3866945D13AF8AF300268560 /* AQAdditions.m */,
+ 3866942D13AF8A1F00268560 /* SortedDictionaryEntry.h */,
+ );
+ path = Public;
+ sourceTree = "<group>";
+ };
/* End PBXGroup section */
/* Begin PBXHeadersBuildPhase section */
@@ -182,6 +385,22 @@
3866938E13AA82C400268560 /* AQNotifyingBitfield.h in Headers */,
3866939513AAA0C600268560 /* AQAppStateMachine.h in Headers */,
3866939A13ABC70300268560 /* AQStateMatchingDescriptor.h in Headers */,
+ 3866942E13AF8A1F00268560 /* AvlTree+Private.h in Headers */,
+ 3866943113AF8A1F00268560 /* AvlTree.h in Headers */,
+ 3866943413AF8A1F00268560 /* common.h in Headers */,
+ 3866943713AF8A1F00268560 /* EntryEnumerator+Private.h in Headers */,
+ 3866943A13AF8A1F00268560 /* EntryEnumerator.h in Headers */,
+ 3866943D13AF8A1F00268560 /* KeyEnumerator.h in Headers */,
+ 3866944013AF8A1F00268560 /* ObjectEnumerator.h in Headers */,
+ 3866944313AF8A1F00268560 /* Node.h in Headers */,
+ 3866944613AF8A1F00268560 /* NSString+Base64.h in Headers */,
+ 3866944913AF8A1F00268560 /* NSString+Indent.h in Headers */,
+ 3866944C13AF8A1F00268560 /* PropertyListReader.h in Headers */,
+ 3866944F13AF8A1F00268560 /* PropertyListWriter.h in Headers */,
+ 3866945213AF8A1F00268560 /* SortedDictionary+Private.h in Headers */,
+ 3866945513AF8A1F00268560 /* MutableSortedDictionary.h in Headers */,
+ 3866945813AF8A1F00268560 /* SortedDictionary.h in Headers */,
+ 3866945B13AF8A1F00268560 /* SortedDictionaryEntry.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -257,6 +476,7 @@
files = (
38431B7113A7C26900178A7E /* InfoPlist.strings in Resources */,
38431B7313A7C26900178A7E /* AQAppStateMachineTests.h in Resources */,
+ 3866940913AF8A1500268560 /* test.plist in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -289,6 +509,22 @@
3866938F13AA82C400268560 /* AQNotifyingBitfield.m in Sources */,
3866939613AAA0C600268560 /* AQAppStateMachine.m in Sources */,
3866939B13ABC70300268560 /* AQStateMatchingDescriptor.m in Sources */,
+ 3866942F13AF8A1F00268560 /* AvlTree+Private.m in Sources */,
+ 3866943213AF8A1F00268560 /* AvlTree.m in Sources */,
+ 3866943513AF8A1F00268560 /* common.m in Sources */,
+ 3866943813AF8A1F00268560 /* EntryEnumerator+Private.m in Sources */,
+ 3866943B13AF8A1F00268560 /* EntryEnumerator.m in Sources */,
+ 3866943E13AF8A1F00268560 /* KeyEnumerator.m in Sources */,
+ 3866944113AF8A1F00268560 /* ObjectEnumerator.m in Sources */,
+ 3866944413AF8A1F00268560 /* Node.m in Sources */,
+ 3866944713AF8A1F00268560 /* NSString+Base64.m in Sources */,
+ 3866944A13AF8A1F00268560 /* NSString+Indent.m in Sources */,
+ 3866944D13AF8A1F00268560 /* PropertyListReader.m in Sources */,
+ 3866945013AF8A1F00268560 /* PropertyListWriter.m in Sources */,
+ 3866945313AF8A1F00268560 /* SortedDictionary+Private.m in Sources */,
+ 3866945613AF8A1F00268560 /* MutableSortedDictionary.m in Sources */,
+ 3866945913AF8A1F00268560 /* SortedDictionary.m in Sources */,
+ 3866945F13AF8AF300268560 /* AQAdditions.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -301,6 +537,30 @@
38AC30BE13AA3D5C00AB071C /* AQBitfieldPredicates.m in Sources */,
3866939713AAA0C600268560 /* AQAppStateMachine.m in Sources */,
3866939C13ABC70300268560 /* AQStateMatchingDescriptor.m in Sources */,
+ 3866940113AF8A1500268560 /* MutableSortedDictionaryContentTests.m in Sources */,
+ 3866940213AF8A1500268560 /* NSStringExtensionsTests.m in Sources */,
+ 3866940313AF8A1500268560 /* SortedDictionary+Test.m in Sources */,
+ 3866940413AF8A1500268560 /* SortedDictionaryContentTests.m in Sources */,
+ 3866940513AF8A1500268560 /* SortedDictionaryCreationTests.m in Sources */,
+ 3866940613AF8A1500268560 /* SortedDictionaryInitializationTests.m in Sources */,
+ 3866940713AF8A1500268560 /* SortedDictionaryProtocolTests.m in Sources */,
+ 3866940813AF8A1500268560 /* SortedDictionarySerializationTests.m in Sources */,
+ 3866943013AF8A1F00268560 /* AvlTree+Private.m in Sources */,
+ 3866943313AF8A1F00268560 /* AvlTree.m in Sources */,
+ 3866943613AF8A1F00268560 /* common.m in Sources */,
+ 3866943913AF8A1F00268560 /* EntryEnumerator+Private.m in Sources */,
+ 3866943C13AF8A1F00268560 /* EntryEnumerator.m in Sources */,
+ 3866943F13AF8A1F00268560 /* KeyEnumerator.m in Sources */,
+ 3866944213AF8A1F00268560 /* ObjectEnumerator.m in Sources */,
+ 3866944513AF8A1F00268560 /* Node.m in Sources */,
+ 3866944813AF8A1F00268560 /* NSString+Base64.m in Sources */,
+ 3866944B13AF8A1F00268560 /* NSString+Indent.m in Sources */,
+ 3866944E13AF8A1F00268560 /* PropertyListReader.m in Sources */,
+ 3866945113AF8A1F00268560 /* PropertyListWriter.m in Sources */,
+ 3866945413AF8A1F00268560 /* SortedDictionary+Private.m in Sources */,
+ 3866945713AF8A1F00268560 /* MutableSortedDictionary.m in Sources */,
+ 3866945A13AF8A1F00268560 /* SortedDictionary.m in Sources */,
+ 3866946013AFB77500268560 /* AQAdditions.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
View
3 AQAppStateMachine/AQAppStateMachine.m
@@ -29,7 +29,7 @@ - (id) init
return ( nil );
// start out with 32 bits
- _stateBits = [[AQNotifyingBitfield alloc] initWithSize: 32];
+ _stateBits = [[AQNotifyingBitfield alloc] init];
_namedRanges = [NSMutableDictionary new];
_matchDescriptors = [NSMutableArray new];
_notifierLookup = [NSMutableDictionary new];
@@ -119,7 +119,6 @@ - (void) addStateMachineValuesUsingBitfieldOfLength: (NSUInteger) length withNam
dispatch_sync(_syncQ, ^{
AQRange * range = [[AQRange alloc] initWithRange: NSMakeRange(_stateBits.count, length)];
[_namedRanges setObject: range forKey: name];
- [_stateBits setCount: NSMaxRange(range.range)];
});
}
View
41 AQAppStateMachine/AQNotifyingBitfield.m
@@ -8,26 +8,22 @@
#import "AQNotifyingBitfield.h"
#import "AQRange.h"
+#import "MutableSortedDictionary.h"
@implementation AQNotifyingBitfield
{
- id _order; // NSMutableArray or NSMutableOrderedSet (if available)
- NSMutableDictionary * _lookup;
- dispatch_queue_t _syncQ;
+ MutableSortedDictionary * _lookup;
+ dispatch_queue_t _syncQ;
+ dispatch_group_t _group;
}
-- (id) initWithSize: (NSUInteger) numberOfBits
+- (id) init
{
- self = [super initWithSize: numberOfBits];
+ self = [super init];
if ( self == nil )
return ( nil );
- if ( [NSMutableOrderedSet self] )
- _order = [NSMutableOrderedSet new];
- else
- _order = [NSMutableArray new];
-
- _lookup = [NSMutableDictionary new];
+ _lookup = [MutableSortedDictionary new];
_syncQ = dispatch_queue_create("net.alanquatermain.notifyingbitfield.sync", DISPATCH_QUEUE_SERIAL);
return ( self );
@@ -43,13 +39,6 @@ - (void) notifyModificationOfBitsInRange: (NSRange) range usingBlock: (AQRangeNo
{
dispatch_async(_syncQ, ^{
AQRange * rangeObject = [[AQRange alloc] initWithRange: range];
- NSUInteger existingIdx = [_order indexOfObject: rangeObject];
- if ( existingIdx == NSNotFound )
- {
- [_order addObject: rangeObject];
- [_order sortUsingSelector: @selector(compare:)];
- }
-
[_lookup setObject: [block copy] forKey: rangeObject];
});
}
@@ -58,17 +47,14 @@ - (void) removeNotifierForBitsInRange: (NSRange) range
{
dispatch_async(_syncQ, ^{
AQRange * obj = [[AQRange alloc] initWithRange: range];
- [_order removeObject: obj];
[_lookup removeObjectForKey: obj];
});
}
- (void) removeAllNotifiersWithinRange: (NSRange) range
{
dispatch_async(_syncQ, ^{
- NSMutableIndexSet * indicesToRemove = [NSMutableIndexSet indexSet];
-
- [_order enumerateObjectsUsingBlock: ^(__strong id obj, NSUInteger idx, BOOL *stop) {
+ [_lookup enumerateKeysAndObjectsUsingBlock: ^(__strong id key, __strong id obj, BOOL *stop) {
NSRange testRange = [obj range];
if ( NSEqualRanges(testRange, NSIntersectionRange(range, testRange)) == NO )
{
@@ -77,11 +63,8 @@ - (void) removeAllNotifiersWithinRange: (NSRange) range
return; // not wholly contained in the input range
}
- [indicesToRemove addIndex: idx];
[_lookup removeObjectForKey: obj];
}];
-
- [_order removeObjectsAtIndexes: indicesToRemove];
});
}
@@ -99,7 +82,7 @@ - (void) flipBitAtIndex: (NSUInteger) index
[super flipBitAtIndex: index];
dispatch_async(_syncQ, ^{
- [_order enumerateObjectsUsingBlock: ^(__strong id obj, NSUInteger idx, BOOL *stop) {
+ [_lookup enumerateKeysAndObjectsUsingBlock: ^(__strong id key, __strong id obj, BOOL *stop) {
if ( NSLocationInRange(index, [obj range]) )
{
[self _scheduleNotificationForRange: obj];
@@ -117,7 +100,7 @@ - (void) flipBitsInRange: (NSRange) range
[super flipBitsInRange: range];
dispatch_async(_syncQ, ^{
- [_order enumerateObjectsUsingBlock: ^(__strong id obj, NSUInteger idx, BOOL *stop) {
+ [_lookup enumerateKeysAndObjectsUsingBlock: ^(__strong id key, __strong id obj, BOOL *stop) {
if ( NSIntersectionRange(range, [obj range]).location != NSNotFound )
{
[self _scheduleNotificationForRange: obj];
@@ -135,7 +118,7 @@ - (void) setBit: (AQBit) bit atIndex: (NSUInteger) index
[super setBit: bit atIndex: index];
dispatch_async(_syncQ, ^{
- [_order enumerateObjectsUsingBlock: ^(__strong id obj, NSUInteger idx, BOOL *stop) {
+ [_lookup enumerateKeysAndObjectsUsingBlock: ^(__strong id key, __strong id obj, BOOL *stop) {
if ( NSLocationInRange(index, [obj range]) )
{
[self _scheduleNotificationForRange: obj];
@@ -153,7 +136,7 @@ - (void) setBitsInRange: (NSRange) range usingBit: (AQBit) bit
[super setBitsInRange: range usingBit: bit];
dispatch_async(_syncQ, ^{
- [_order enumerateObjectsUsingBlock: ^(__strong id obj, NSUInteger idx, BOOL *stop) {
+ [_lookup enumerateKeysAndObjectsUsingBlock: ^(__strong id key, __strong id obj, BOOL *stop) {
if ( NSIntersectionRange(range, [obj range]).location != NSNotFound )
{
[self _scheduleNotificationForRange: obj];
View
4 AQAppStateMachine/AQStateMatchingDescriptor.m
@@ -122,7 +122,7 @@ - (id) initWithRange: (NSRange) range matchingMask: (AQBitfield *) mask
- (id) initWith32BitMask: (NSUInteger) mask forRange: (NSRange) range
{
- AQBitfield * field = [[AQBitfield alloc] initWithSize: 32];
+ AQBitfield * field = [[AQBitfield alloc] init];
for ( NSUInteger i = 0; mask != 0; mask >>= 1, i++ )
{
if ( mask & 1 )
@@ -135,7 +135,7 @@ - (id) initWith32BitMask: (NSUInteger) mask forRange: (NSRange) range
- (id) initWith64BitMask: (UInt64) mask forRange: (NSRange) range
{
- AQBitfield * field = [[AQBitfield alloc] initWithSize: 64];
+ AQBitfield * field = [[AQBitfield alloc] init];
for ( UInt64 i = 0; mask != 0; mask >>= 1, i++ )
{
if ( mask & 1 )
View
5 AQAppStateMachine/SortedDictionary/.svn/all-wcprops
@@ -0,0 +1,5 @@
+K 25
+svn:wc:ra_dav:version-url
+V 38
+/svn/!svn/ver/2/trunk/SortedDictionary
+END
View
34 AQAppStateMachine/SortedDictionary/.svn/entries
@@ -0,0 +1,34 @@
+8
+
+dir
+2
+https://orentrutner@cocoa-sorted-dictionary.googlecode.com/svn/trunk/SortedDictionary
+https://orentrutner@cocoa-sorted-dictionary.googlecode.com/svn
+
+
+
+2009-07-23T05:28:27.699070Z
+2
+orentrutner
+
+
+svn:special svn:externals svn:needs-lock
+
+
+
+
+
+
+
+
+
+
+
+4c890986-7748-11de-8e60-65c8b4fa459e
+
+Internal
+dir
+
+Public
+dir
+
View
1 AQAppStateMachine/SortedDictionary/.svn/format
@@ -0,0 +1 @@
+8
View
89 AQAppStateMachine/SortedDictionary/Internal/.svn/all-wcprops
@@ -0,0 +1,89 @@
+K 25
+svn:wc:ra_dav:version-url
+V 47
+/svn/!svn/ver/2/trunk/SortedDictionary/Internal
+END
+NSString+Indent.m
+K 25
+svn:wc:ra_dav:version-url
+V 65
+/svn/!svn/ver/2/trunk/SortedDictionary/Internal/NSString+Indent.m
+END
+Node.m
+K 25
+svn:wc:ra_dav:version-url
+V 54
+/svn/!svn/ver/2/trunk/SortedDictionary/Internal/Node.m
+END
+NSString+Base64.m
+K 25
+svn:wc:ra_dav:version-url
+V 65
+/svn/!svn/ver/2/trunk/SortedDictionary/Internal/NSString+Base64.m
+END
+SortedDictionary+Private.h
+K 25
+svn:wc:ra_dav:version-url
+V 74
+/svn/!svn/ver/2/trunk/SortedDictionary/Internal/SortedDictionary+Private.h
+END
+common.m
+K 25
+svn:wc:ra_dav:version-url
+V 56
+/svn/!svn/ver/2/trunk/SortedDictionary/Internal/common.m
+END
+AvlTree+Private.m
+K 25
+svn:wc:ra_dav:version-url
+V 65
+/svn/!svn/ver/2/trunk/SortedDictionary/Internal/AvlTree+Private.m
+END
+SortedDictionary+Private.m
+K 25
+svn:wc:ra_dav:version-url
+V 74
+/svn/!svn/ver/2/trunk/SortedDictionary/Internal/SortedDictionary+Private.m
+END
+AvlTree.h
+K 25
+svn:wc:ra_dav:version-url
+V 57
+/svn/!svn/ver/2/trunk/SortedDictionary/Internal/AvlTree.h
+END
+NSString+Indent.h
+K 25
+svn:wc:ra_dav:version-url
+V 65
+/svn/!svn/ver/2/trunk/SortedDictionary/Internal/NSString+Indent.h
+END
+Node.h
+K 25
+svn:wc:ra_dav:version-url
+V 54
+/svn/!svn/ver/2/trunk/SortedDictionary/Internal/Node.h
+END
+AvlTree.m
+K 25
+svn:wc:ra_dav:version-url
+V 57
+/svn/!svn/ver/2/trunk/SortedDictionary/Internal/AvlTree.m
+END
+NSString+Base64.h
+K 25
+svn:wc:ra_dav:version-url
+V 65
+/svn/!svn/ver/2/trunk/SortedDictionary/Internal/NSString+Base64.h
+END
+AvlTree+Private.h
+K 25
+svn:wc:ra_dav:version-url
+V 65
+/svn/!svn/ver/2/trunk/SortedDictionary/Internal/AvlTree+Private.h
+END
+common.h
+K 25
+svn:wc:ra_dav:version-url
+V 56
+/svn/!svn/ver/2/trunk/SortedDictionary/Internal/common.h
+END
View
202 AQAppStateMachine/SortedDictionary/Internal/.svn/entries
@@ -0,0 +1,202 @@
+8
+
+dir
+2
+https://orentrutner@cocoa-sorted-dictionary.googlecode.com/svn/trunk/SortedDictionary/Internal
+https://orentrutner@cocoa-sorted-dictionary.googlecode.com/svn
+
+
+
+2009-07-23T05:28:27.699070Z
+2
+orentrutner
+
+
+svn:special svn:externals svn:needs-lock
+
+
+
+
+
+
+
+
+
+
+
+4c890986-7748-11de-8e60-65c8b4fa459e
+
+NSString+Indent.m
+file
+
+
+
+
+2009-07-23T05:35:11.000000Z
+932c55f6aae15c24698c3a18e383b3da
+2009-07-23T05:28:27.699070Z
+2
+orentrutner
+
+Node.m
+file
+
+
+
+
+2009-07-23T05:35:11.000000Z
+7efbd3676849432b488ed9f26ba93f41
+2009-07-23T05:28:27.699070Z
+2
+orentrutner
+
+SortedDictionary+Private.h
+file
+
+
+
+
+2009-07-23T05:35:11.000000Z
+b35145a18f9c4c0c718a63d31ffd71fb
+2009-07-23T05:28:27.699070Z
+2
+orentrutner
+
+NSString+Base64.m
+file
+
+
+
+
+2009-07-23T05:35:11.000000Z
+f4701bbd74fc2899193805a19fd26808
+2009-07-23T05:28:27.699070Z
+2
+orentrutner
+
+common.m
+file
+
+
+
+
+2009-07-23T05:35:11.000000Z
+bad7fc97cb6a23d4fcd08356c3617d10
+2009-07-23T05:28:27.699070Z
+2
+orentrutner
+
+SortedDictionary+Private.m
+file
+
+
+
+
+2009-07-23T05:35:11.000000Z
+a291e2ae1a5fe1d7c2b2d302438881f2
+2009-07-23T05:28:27.699070Z
+2
+orentrutner
+
+AvlTree.h
+file
+
+
+
+
+2009-07-23T05:35:11.000000Z
+d57f9c881b09e5cf5394ac79aa03955e
+2009-07-23T05:28:27.699070Z
+2
+orentrutner
+
+AvlTree.m
+file
+
+
+
+
+2009-07-23T05:35:11.000000Z
+ee9fd47c6c4b471d515371c577a6f3d7
+2009-07-23T05:28:27.699070Z
+2
+orentrutner
+
+AvlTree+Private.h
+file
+
+
+
+
+2009-07-23T05:35:11.000000Z
+b7f0e26e57b5854b53a50fe641d4a16a
+2009-07-23T05:28:27.699070Z
+2
+orentrutner
+
+AvlTree+Private.m
+file
+
+
+
+
+2009-07-23T05:35:11.000000Z
+fc3cec40f3a3368dd1e14a51e58251da
+2009-07-23T05:28:27.699070Z
+2
+orentrutner
+
+Enumerators
+dir
+
+NSString+Indent.h
+file
+
+
+
+
+2009-07-23T05:35:11.000000Z
+b9090f4ba91d9f329241bc80a587366b
+2009-07-23T05:28:27.699070Z
+2
+orentrutner
+
+Node.h
+file
+
+
+
+
+2009-07-23T05:35:11.000000Z
+0579ceebfa573914152e845e5a8dd780
+2009-07-23T05:28:27.699070Z
+2
+orentrutner
+
+NSString+Base64.h
+file
+
+
+
+
+2009-07-23T05:35:11.000000Z
+d8dbf2e833fd026165dbe0347fe6b706
+2009-07-23T05:28:27.699070Z
+2
+orentrutner
+
+Serialization
+dir
+
+common.h
+file
+
+
+
+
+2009-07-23T05:35:11.000000Z
+ea81f8250a3c241ba251df03352fdaaa
+2009-07-23T05:28:27.699070Z
+2
+orentrutner
+
View
1 AQAppStateMachine/SortedDictionary/Internal/.svn/format
@@ -0,0 +1 @@
+8
View
9 AQAppStateMachine/SortedDictionary/Internal/.svn/text-base/AvlTree+Private.h.svn-base
@@ -0,0 +1,9 @@
+#import <Foundation/Foundation.h>
+#import "AvlTree.h"
+
+
+@interface AvlTree (Private)
+
+ - (id) initWithNode: (Node *) newRoot andCount: (NSUInteger) newCount;
+
+@end
View
16 AQAppStateMachine/SortedDictionary/Internal/.svn/text-base/AvlTree+Private.m.svn-base
@@ -0,0 +1,16 @@
+#import "AvlTree+Private.h"
+
+
+@implementation AvlTree (Private)
+
+
+- (id) initWithNode: (Node *) newRoot andCount: (NSUInteger) newCount {
+ if (self = [super init]) {
+ root = [newRoot retain];
+ count = newCount;
+ }
+ return self;
+}
+
+
+@end
View
36 AQAppStateMachine/SortedDictionary/Internal/.svn/text-base/AvlTree.h.svn-base
@@ -0,0 +1,36 @@
+#import <Cocoa/Cocoa.h>
+
+
+@class Node;
+
+
+@interface AvlTree : NSObject <NSCopying> {
+ Node *root;
+ NSUInteger count;
+ }
+
+ @property (readonly, nonatomic) Node *root;
+ @property (readonly, nonatomic) NSUInteger count;
+
+ - (id) init;
+
+ - (BOOL) containsKey: (id) aKey;
+ - (id) objectForKey: (id) aKey;
+
+ - (NSEnumerator *) entryEnumerator;
+ - (NSEnumerator *) reverseEntryEnumerator;
+
+ - (void) setObject: (id) anObject forKey: (id) aKey;
+ - (void) removeAllObjects;
+ - (void) removeObjectForKey: (id) aKey;
+
+ - (NSString *) description;
+
+ // NSCoding
+ - (void) encodeWithCoder: (NSCoder *) encoder;
+ - (id) initWithCoder: (NSCoder *) decoder;
+
+ // NSCopying
+ - (id) copyWithZone: (NSZone *) zone;
+
+@end
View
273 AQAppStateMachine/SortedDictionary/Internal/.svn/text-base/AvlTree.m.svn-base
@@ -0,0 +1,273 @@
+#import "AvlTree.h"
+#import "AvlTree+Private.h"
+#import "common.h"
+#import "Node.h"
+#import "EntryEnumerator.h"
+#import "EntryEnumerator+Private.h"
+#import "KeyEnumerator.h"
+#import "ObjectEnumerator.h"
+
+
+#define DIR(side) (((side) == odLeft) ? -1 : 1)
+
+
+@implementation AvlTree
+
+
+@synthesize root, count;
+
+
+// initializer
+- (id) init {
+ if (self = [super init]) {
+ root = nil;
+ count = 0;
+ }
+ return self;
+}
+
+
+// destructor
+- (void) dealloc {
+ [root release];
+ [super dealloc];
+}
+
+
+// private methods
+
+// finds a node with the specified key in the tree, or a node with a nearby key that a new node
+// with the specified key could be added to.
+- (Node *) findNodeWithKey: (id) aKey orNearest: (BOOL) findNearest {
+ Node *node, *child;
+
+ for (node = root; node && ![aKey isEqual: [node key]]; node = child) {
+ if (!(child = [node childAtSide: [aKey isLessThan: [node key]] ? odLeft : odRight])) {
+ return findNearest ? node : nil;
+ }
+ }
+
+ return node;
+}
+
+
+- (Node *) lastNodeFrom: (Node *) first usingSelector: (SEL) next {
+ Node *node = first, *nextNode;
+ while (nextNode = [node performSelector: next]) { node = nextNode; }
+ return node;
+}
+
+
+- (Node *) leftmostDescendantOf: (Node *) node { return [self lastNodeFrom: node usingSelector: @selector(left)]; }
+- (Node *) rightmostDescendantOf: (Node *) node { return [self lastNodeFrom: node usingSelector: @selector(right)]; }
+- (Node *) nearestLowerDescendantOf: (Node *) node { return [self rightmostDescendantOf: [node left]] ; }
+- (Node *) nearestHigherDescendantOf: (Node *) node { return [self leftmostDescendantOf: [node right]]; }
+
+
+- (Node *) nearDescendantOf: (Node *) node {
+ return [node left] ?
+ [self nearestLowerDescendantOf: node] :
+ [self nearestHigherDescendantOf: node];
+}
+
+
+// rolls the node once to the specified side. returns the node that was rolled into place instead
+// of the original node.
+- (Node *) rollNode: (Node *) node onceToSide: (ODSide) aSide {
+ ODSide otherSide = 1 - aSide;
+ int dir = DIR(aSide);
+ Node *parent = [node parent];
+
+ NSAssert([node childAtSide: otherSide], @"Did not find a node to roll");
+
+ // newTop will come up on top after the roll
+ Node *newTop = [node childAtSide: otherSide];
+
+ if (parent) { [parent setChild: newTop atSide: [parent sideOfChild: node]]; }
+ else { root = newTop; [newTop setParent: nil]; }
+
+ [node setChild: [newTop childAtSide: aSide] atSide: otherSide];
+ [newTop setChild: node atSide: aSide];
+
+ // update the node balances
+ node.balance += dir * (1 + max(0, -dir * newTop.balance));
+ newTop.balance += dir * (1 + max(0, dir * node.balance));
+
+ return newTop;
+}
+
+
+// rolls the node to the specified side. also rolls the rolled child if needed to minimize the
+// height of the tree.
+- (Node *) rollNode: (Node *) node toSide: (ODSide) aSide {
+ ODSide otherSide = 1 - aSide;
+ Node *newTop = [node childAtSide: otherSide];
+
+ // if needed, roll the rolled child node to minimize the height of the tree
+ if (DIR(aSide) * [newTop balance] > 0) {
+ [self rollNode: newTop onceToSide: otherSide];
+ }
+
+ // roll the specified node and return the node that was rolled in to replace it
+ return [self rollNode: node onceToSide: aSide];
+}
+
+
+// recursively updates the ancestor chain of the specified node to a change in the height of one
+// of its children. O(log n)
+- (void) updateNode: (Node *) node toHeightChange: (int) heightChange atSide: (ODSide) aSide {
+ int dir = DIR(aSide);
+ Node *rolledNode = node;
+ Node *originalParent = [node parent];
+ int parentHeightChange = 0;
+
+ // update the node's balance. the tree underneath the node should now be correctly balanced.
+ node.balance += dir * heightChange;
+ int balance = node.balance;
+
+ // if the node is out of balance, roll it
+ if (abs(balance) > 1) {
+ ODSide rollSide = (balance > 0) ? odLeft : odRight;
+ rolledNode = [self rollNode: node toSide: rollSide];
+ parentHeightChange = DIR(rollSide) * [[rolledNode childAtSide: rollSide] balance] >= 0 ?
+ min(heightChange, 0) :
+ 0;
+ }
+ // figure out if the node's height has changed
+ else if ((dir * balance > 0) && (heightChange > 0)) { parentHeightChange = 1; }
+ else if ((dir * balance >= 0) && (heightChange < 0)) { parentHeightChange = -1; }
+
+ // if the node's height has changed, recursively update the node's parent
+ if (originalParent && (parentHeightChange != 0)) {
+ [self updateNode: originalParent
+ toHeightChange: parentHeightChange
+ atSide: [originalParent sideOfChild: rolledNode]];
+ }
+}
+
+
+// public methods
+
+- (BOOL) containsKey: (id) aKey { return [self findNodeWithKey: aKey orNearest: NO] != nil; }
+- (id) objectForKey: (id) aKey { return [[self findNodeWithKey: aKey orNearest: NO] value]; }
+
+// enumerators
+- (NSEnumerator *) entryEnumerator { return [[[EntryEnumerator alloc] initGoingForwardFromNode: [self leftmostDescendantOf: root]] autorelease]; }
+- (NSEnumerator *) reverseEntryEnumerator { return [[[EntryEnumerator alloc] initGoingBackFromNode: [self rightmostDescendantOf: root]] autorelease]; }
+
+
+- (void) setObject: (id) anObject forKey: (id) aKey {
+ // tree empty? -- create first node and return -- O(1)
+ if (!root) {
+ NSAssert(count == 0, @"Expected a zero count when there is no root node");
+ root = [[Node alloc] initWithKey: aKey value: anObject andParent: nil];
+ count = 1;
+ return;
+ }
+
+ // node with key already in tree? -- update its value and return -- O(log n)
+ Node *node = [self findNodeWithKey: aKey orNearest: YES];
+ if ([aKey isEqual: [node key]]) {
+ [node setValue: anObject];
+ return;
+ }
+
+ // create a new node and add it as a child of the nearest node
+ ODSide side = [aKey isLessThan: [node key]] ? odLeft : odRight;
+ Node *newNode = [[Node alloc] initWithKey: aKey value: anObject andParent: node];
+
+ [node setChild: newNode atSide: side];
+ node.balance += DIR(side);
+
+ // update the chain of ancestors about the height change
+ Node *parent = [node parent];
+ if (parent && ![node childAtSide: 1 - side]) {
+ [self updateNode: parent toHeightChange: 1 atSide: [parent sideOfChild: node]];
+ }
+
+ // update the cached entry count
+ ++count;
+}
+
+
+- (void) removeAllObjects {
+ [root release];
+ root = nil;
+ count = 0;
+}
+
+
+- (void) removeObjectForKey: (id) aKey {
+ if (!root) { return; }
+
+ // find the node to remove; exit if not found -- O(log n)
+ Node *nodeToRemove = [self findNodeWithKey: aKey orNearest: NO];
+ if (!nodeToRemove) { return; }
+
+ // replace the key/value content of the node with that of its nearest descendant -- O(1)
+ Node *nearestDescendant = [self nearDescendantOf: nodeToRemove];
+ if (nearestDescendant) {
+ [nodeToRemove copyContentFromNode: nearestDescendant];
+ nodeToRemove = nearestDescendant;
+ }
+
+ // find the node's one child -- O(1)
+ Node *replacement = [nodeToRemove liveChild];
+
+ // remove the node from the tree -- O(log n)
+ if (![nodeToRemove parent]) {
+ root = replacement;
+ }
+ else {
+ // remove the node -- O(1)
+ Node *parent = [nodeToRemove parent];
+ ODSide sideAtParent = [parent sideOfChild: nodeToRemove];
+ [parent setChild: replacement atSide: sideAtParent];
+
+ // update the chain of anscesors about the change in height -- O(log n)
+ [self updateNode: parent toHeightChange: -1 atSide: sideAtParent];
+ }
+
+ // release the node -- O(1)
+ [nodeToRemove setChild: nil atSide: odLeft];
+ [nodeToRemove setChild: nil atSide: odRight];
+ [nodeToRemove release];
+
+ // update the cached entry count
+ --count;
+}
+
+
+- (NSString *) description {
+ return [NSString stringWithFormat: @"{%@ count=%d\n root=%@\n}",
+ [super description],
+ count,
+ [root descriptionWithChildrenAndIndent: 1]];
+}
+
+
+// NSCoding protocol implementation
+
+- (void) encodeWithCoder: (NSCoder *) encoder {
+ [encoder encodeObject: root forKey: @"Root"];
+ [encoder encodeInteger: count forKey: @"Count"];
+}
+
+
+- (id) initWithCoder: (NSCoder *) decoder {
+ if (self = [super init]) {
+ root = [[decoder decodeObjectForKey: @"Root"] retain];
+ count = [decoder decodeIntegerForKey: @"Count"];
+ }
+ return self;
+}
+
+
+// NSCopying protocol implementation
+
+- (id) copyWithZone: (NSZone *) zone {
+ return [[AvlTree alloc] initWithNode: [[root copyWithZone: zone] autorelease] andCount: count];
+}
+
+
+@end
View
12 AQAppStateMachine/SortedDictionary/Internal/.svn/text-base/NSString+Base64.h.svn-base
@@ -0,0 +1,12 @@
+#import <Cocoa/Cocoa.h>
+
+
+/**
+ Extends the NSString class to support Base64 encoding and decoding.
+ */
+@interface NSString (Base64)
+
+ - (NSData *) decodeBase64;
+ + (id) encodeBase64: (NSData *) data;
+
+@end
View
61 AQAppStateMachine/SortedDictionary/Internal/.svn/text-base/NSString+Base64.m.svn-base
@@ -0,0 +1,61 @@
+#import "NSString+Base64.h"
+#import "common.h"
+
+
+@implementation NSString (Base64)
+
+
+static NSString *base64chars = @"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
+
+
+- (NSData *) decodeBase64 {
+ int length = [self length];
+ NSMutableData *data = [[[NSMutableData alloc] initWithCapacity: length * 3 / 4] autorelease];
+
+ for (int i = 0; i < length; i += 4) {
+ Byte quad[4];
+ Byte triplet[3];
+
+ quad[0] = [base64chars rangeOfString: [self substringWithRange: NSMakeRange(i , 1)]].location;
+ quad[1] = [base64chars rangeOfString: [self substringWithRange: NSMakeRange(i + 1, 1)]].location;
+ quad[2] = [base64chars rangeOfString: [self substringWithRange: NSMakeRange(i + 2, 1)]].location;
+ quad[3] = [base64chars rangeOfString: [self substringWithRange: NSMakeRange(i + 3, 1)]].location;
+
+ triplet[0] = (quad[0] << 2) | (quad[1] >> 4);
+ triplet[1] = ((quad[1] & 15) << 4) | (quad[2] >> 2);
+ triplet[2] = ((quad[2] & 3) << 6) | quad[3];
+
+ [data appendBytes: triplet length: (quad[2] != 64) ? ((quad[3] != 64) ? 3 : 2) : 1];
+ }
+
+ return data;
+}
+
+
++ (id) encodeBase64: (NSData *) data {
+ int length = [data length];
+ NSMutableString *base64 = [[[NSMutableString alloc] init] autorelease];
+
+ for (int i = 0; i < length; i += 3) {
+ Byte triplet[3];
+ unichar quad[4];
+
+ triplet[1] = triplet[2] = 0;
+ [data getBytes: triplet range: NSMakeRange(i, min(3, length - i))];
+
+ quad[0] = [base64chars characterAtIndex: triplet[0] >> 2];
+ quad[1] = [base64chars characterAtIndex: ((triplet[0] & 3) << 4) | (triplet[1] >> 4)];
+ quad[2] = [base64chars characterAtIndex: ((triplet[1] & 15) << 2) | (triplet[2] >> 6)];
+ quad[3] = [base64chars characterAtIndex: triplet[2] & 63];
+
+ if (i + 1 >= length) { quad[2] = '='; }
+ if (i + 2 >= length) { quad[3] = '='; }
+
+ [base64 appendString: [NSString stringWithCharacters: quad length: 4]];
+ }
+
+ return base64;
+}
+
+
+@end
View
11 AQAppStateMachine/SortedDictionary/Internal/.svn/text-base/NSString+Indent.h.svn-base
@@ -0,0 +1,11 @@
+#import <Cocoa/Cocoa.h>
+
+
+/**
+ Extends the NSString class to simplify the indentation of strings written to some output.
+ */
+@interface NSString (Indent)
+
++ (NSString *) stringWith: (NSInteger) count copiesOfString: (NSString *) copyMe;
+
+@end
View
27 AQAppStateMachine/SortedDictionary/Internal/.svn/text-base/NSString+Indent.m.svn-base
@@ -0,0 +1,27 @@
+#import "NSString+Indent.h"
+
+
+@implementation NSString (Indent)
+
+
+/**
+ \brief Returns a string containing \a count copies of the \a copyMe string.
+
+ \return A string containing \a count concatenated copies of the \a copyMe string.
+
+ \param count The number of times to copy \a copyMe.
+ \param copyMe The string to copy and concatenate. For indentation, this is often a string of
+ one or more whitespaces or tab characters.
+ */
++ (NSString *) stringWith: (NSInteger) count copiesOfString: (NSString *) copyMe {
+ NSMutableString *result = [[NSMutableString alloc] initWithCapacity: count * [copyMe length]];
+
+ for (int i = 0; i < count; ++i) {
+ [result appendString: copyMe];
+ }
+
+ return result;
+}
+
+
+@end
View
45 AQAppStateMachine/SortedDictionary/Internal/.svn/text-base/Node.h.svn-base
@@ -0,0 +1,45 @@
+#import <Cocoa/Cocoa.h>
+#import "SortedDictionaryEntry.h"
+
+
+typedef enum { odLeft = 0, odRight = 1 } ODSide;
+
+
+@interface Node : NSObject <NSCoding, NSCopying, SortedDictionaryEntry> {
+ id key;
+ id value;
+ int balance;
+ Node *parent;
+ Node *children[2];
+ }
+
+ @property (copy, nonatomic) id key;
+ @property (retain, nonatomic) id value;
+ @property (assign, nonatomic) int balance;
+ @property (assign, nonatomic) Node *parent;
+ @property (assign, nonatomic) Node *left;
+ @property (assign, nonatomic) Node *right;
+
+ - (id) initWithKey: (id) aKey value: (id) aValue andParent: (Node *) aParent;
+ - (void) copyContentFromNode: (Node *) aNode;
+
+ - (Node *) childAtSide: (ODSide) aSide;
+ - (void) setChild: (Node *) aNode atSide: (ODSide) aSide;
+
+ - (Node *) liveChild;
+ - (ODSide) sideOfChild: (Node *) aNode;
+
+ - (int) height;
+ - (int) count;
+
+ - (NSString *) description;
+ - (NSString *) descriptionWithChildrenAndIndent: (NSInteger) indent;
+
+ // NSCoding
+ - (void) encodeWithCoder: (NSCoder *) encoder;
+ - (id) initWithCoder: (NSCoder *) decoder;
+
+ // NSCopying
+ - (id) copyWithZone: (NSZone *) zone;
+
+@end
View
124 AQAppStateMachine/SortedDictionary/Internal/.svn/text-base/Node.m.svn-base
@@ -0,0 +1,124 @@
+#import "Node.h"
+#import "common.h"
+#import "NSString+Indent.h"
+
+
+@implementation Node
+
+
+@synthesize key, value, balance, parent;
+
+
+// initializer
+- (id) initWithKey: (id) aKey value: (id) aValue andParent: (Node *) aParent {
+ if (self = [super init]) {
+ self.key = aKey;
+ self.value = aValue;
+ balance = 0;
+ parent = aParent;
+ children[odLeft] = nil;
+ children[odRight] = nil;
+ }
+ return self;
+}
+
+
+// destructor
+- (void) dealloc {
+ [children[odRight] release];
+ [children[odLeft] release];
+ [value release];
+ [key release];
+ [super dealloc];
+}
+
+
+// explicit property accessors
+
+- (Node *) left { return children[odLeft]; }
+- (void) setLeft: (Node *) aNode { [self setChild: aNode atSide: odLeft]; }
+
+- (Node *) right { return children[odRight]; }
+- (void) setRight: (Node *) aNode { [self setChild: aNode atSide: odRight]; }
+
+
+// public methods
+
+- (void) copyContentFromNode: (Node *) aNode { [self setKey: [aNode key]]; [self setValue: [aNode value]]; }
+
+- (Node *) childAtSide: (ODSide) aSide { return children[aSide]; }
+- (void) setChild: (Node *) aNode atSide: (ODSide) aSide {
+ children[aSide] = aNode;
+ [aNode setParent: self];
+}
+
+- (Node *) liveChild { return children[odLeft] ? children[odLeft] : children[odRight]; }
+- (ODSide) sideOfChild: (Node *) aNode { return (children[odLeft] == aNode) ? odLeft : odRight; }
+
+
+- (int) height { return 1 + max([children[odLeft] height], [children[odRight] height]); }
+- (int) count { return 1 + [children[odLeft] count] + [children[odRight] count]; }
+
+
+- (NSString *) description {
+ int expectedBalance = [[self right] height] - [[self left] height];
+ return [NSString stringWithFormat: @"<%@>=<%@> H=%d B=%d/%d CNT=%d%@",
+ [key description], [value description],
+ [self height], balance, expectedBalance, [self count],
+ (balance == expectedBalance) ? @"" : @" *** BUG: balance mismatch"];
+}
+
+
+- (NSString *) descriptionWithChildrenAndIndent: (NSInteger) indent {
+ NSString *indentString = @" ";
+ NSMutableString *description = [NSMutableString stringWithFormat: @"%@", [self description]];
+
+ if (children[odLeft]) { [description appendFormat: @"\n%@left: %@",
+ [NSString stringWith: indent + 1 copiesOfString: indentString],
+ [children[odLeft] descriptionWithChildrenAndIndent: indent + 1]]; }
+
+ if (children[odRight]) { [description appendFormat: @"\n%@right: %@",
+ [NSString stringWith: indent + 1 copiesOfString: indentString],
+ [children[odRight] descriptionWithChildrenAndIndent: indent + 1]]; }
+
+ return description;
+}
+
+
+// NSCoding protocol implementation
+
+- (void) encodeWithCoder: (NSCoder *) encoder {
+ [encoder encodeObject: key forKey: @"Key"];
+ [encoder encodeObject: value forKey: @"Value"];
+ [encoder encodeInteger: balance forKey: @"Balance"];
+ [encoder encodeObject: children[odLeft] forKey: @"Left"];
+ [encoder encodeObject: children[odRight] forKey: @"Right"];
+}
+
+
+- (id) initWithCoder: (NSCoder *) decoder {
+ if (self = [super init]) {
+ self.key = [decoder decodeObjectForKey: @"Key"];
+ self.value = [decoder decodeObjectForKey: @"Value"];
+ balance = [decoder decodeIntegerForKey: @"Balance"];
+ parent = nil;
+ self.left = [[decoder decodeObjectForKey: @"Left"] retain];
+ self.right = [[decoder decodeObjectForKey: @"Right"] retain];
+ }
+ return self;
+}
+
+
+// NSCopying protocol implementation
+
+- (id) copyWithZone: (NSZone *) zone {
+ Node *copy = [[Node alloc] initWithKey: key value: value andParent: parent];
+ copy.balance = balance;
+ copy.left = [children[odLeft] copyWithZone: zone];
+ copy.right = [children[odRight] copyWithZone: zone];
+
+ return copy;
+}
+
+
+@end
View
11 ...StateMachine/SortedDictionary/Internal/.svn/text-base/SortedDictionary+Private.h.svn-base
@@ -0,0 +1,11 @@
+#import <Cocoa/Cocoa.h>
+#import "SortedDictionary.h"
+
+
+@interface SortedDictionary (Private)
+
+ - initWithTree: (AvlTree *) newTree;
+ - (void) addEntriesFromDictionary: (NSDictionary *) otherDictionary copyItems: (BOOL) flag;
+ - (void) addEntriesFromSortedDictionary: (SortedDictionary *) otherDictionary copyItems: (BOOL) flag;
+
+@end
View
32 ...StateMachine/SortedDictionary/Internal/.svn/text-base/SortedDictionary+Private.m.svn-base
@@ -0,0 +1,32 @@
+#import "SortedDictionary+Private.h"
+#import "AvlTree.h"
+#import "EntryEnumerator.h"
+
+
+@implementation SortedDictionary (Private)
+
+
+- initWithTree: (AvlTree *) newTree {
+ if (self = [super init]) {
+ tree = [newTree retain];
+ }
+ return self;
+}
+
+
+- (void) addEntriesFromDictionary: (NSDictionary *) otherDictionary copyItems: (BOOL) flag {
+ for (id key in [otherDictionary keyEnumerator]) {
+ id value = [otherDictionary objectForKey: key];
+ [tree setObject: (flag ? [[value copy] autorelease] : value) forKey: key];
+ }
+}
+
+
+- (void) addEntriesFromSortedDictionary: (SortedDictionary *) otherDictionary copyItems: (BOOL) flag {
+ for (NSObject<SortedDictionaryEntry> *entry in [otherDictionary entryEnumerator]) {
+ [tree setObject: (flag ? [[[entry value] copy] autorelease] : [entry value]) forKey: [entry key]];
+ }
+}
+
+
+@end
View
2 AQAppStateMachine/SortedDictionary/Internal/.svn/text-base/common.h.svn-base
@@ -0,0 +1,2 @@
+int max(int a, int b);
+int min(int a, int b);
View
5 AQAppStateMachine/SortedDictionary/Internal/.svn/text-base/common.m.svn-base
@@ -0,0 +1,5 @@
+#import "common.h"
+
+
+int max(int a, int b) { return (a >= b) ? a : b; }
+int min(int a, int b) { return (a <= b) ? a : b; }
View
9 AQAppStateMachine/SortedDictionary/Internal/AvlTree+Private.h
@@ -0,0 +1,9 @@
+#import <Foundation/Foundation.h>
+#import "AvlTree.h"
+
+
+@interface AvlTree (Private)
+
+ - (id) initWithNode: (Node *) newRoot andCount: (NSUInteger) newCount;
+
+@end
View
16 AQAppStateMachine/SortedDictionary/Internal/AvlTree+Private.m
@@ -0,0 +1,16 @@
+#import "AvlTree+Private.h"
+
+
+@implementation AvlTree (Private)
+
+
+- (id) initWithNode: (Node *) newRoot andCount: (NSUInteger) newCount {
+ if (self = [super init]) {
+ root = newRoot;//[newRoot retain];
+ count = newCount;
+ }
+ return self;
+}
+
+
+@end
View
36 AQAppStateMachine/SortedDictionary/Internal/AvlTree.h
@@ -0,0 +1,36 @@
+#import <Foundation/Foundation.h>
+
+
+@class Node;
+
+
+@interface AvlTree : NSObject <NSCopying> {
+ Node *root;
+ NSUInteger count;
+ }
+
+ @property (readonly, nonatomic) Node *root;
+ @property (readonly, nonatomic) NSUInteger count;
+
+ - (id) init;
+
+ - (BOOL) containsKey: (id) aKey;
+ - (id) objectForKey: (id) aKey;
+
+ - (NSEnumerator *) entryEnumerator;
+ - (NSEnumerator *) reverseEntryEnumerator;
+
+ - (void) setObject: (id) anObject forKey: (id) aKey;
+ - (void) removeAllObjects;
+ - (void) removeObjectForKey: (id) aKey;
+
+ - (NSString *) description;
+
+ // NSCoding
+ - (void) encodeWithCoder: (NSCoder *) encoder;
+ - (id) initWithCoder: (NSCoder *) decoder;
+
+ // NSCopying
+ - (id) copyWithZone: (NSZone *) zone;
+
+@end
View
273 AQAppStateMachine/SortedDictionary/Internal/AvlTree.m
@@ -0,0 +1,273 @@
+#import "AvlTree.h"
+#import "AvlTree+Private.h"
+#import "common.h"
+#import "Node.h"
+#import "EntryEnumerator.h"
+#import "EntryEnumerator+Private.h"
+#import "KeyEnumerator.h"
+#import "ObjectEnumerator.h"
+
+
+#define DIR(side) (((side) == odLeft) ? -1 : 1)
+
+
+@implementation AvlTree
+
+
+@synthesize root, count;
+
+
+// initializer
+- (id) init {
+ if (self = [super init]) {
+ root = nil;
+ count = 0;
+ }
+ return self;
+}
+
+/*
+// destructor
+- (void) dealloc {
+ [root release];
+ [super dealloc];
+}
+*/
+
+// private methods
+
+// finds a node with the specified key in the tree, or a node with a nearby key that a new node
+// with the specified key could be added to.
+- (Node *) findNodeWithKey: (id) aKey orNearest: (BOOL) findNearest {
+ Node *node, *child;
+
+ for (node = root; node && ![aKey isEqual: [node key]]; node = child) {
+ if (!(child = [node childAtSide: ([aKey compare: [node key]] == NSOrderedAscending) ? odLeft : odRight])) {
+ return findNearest ? node : nil;
+ }
+ }
+
+ return node;
+}
+
+
+- (Node *) lastNodeFrom: (Node *) first usingSelector: (SEL) next {
+ Node *node = first, *nextNode;
+ while ((nextNode = [node performSelector: next])) { node = nextNode; }
+ return node;
+}
+
+
+- (Node *) leftmostDescendantOf: (Node *) node { return [self lastNodeFrom: node usingSelector: @selector(left)]; }
+- (Node *) rightmostDescendantOf: (Node *) node { return [self lastNodeFrom: node usingSelector: @selector(right)]; }
+- (Node *) nearestLowerDescendantOf: (Node *) node { return [self rightmostDescendantOf: [node left]] ; }
+- (Node *) nearestHigherDescendantOf: (Node *) node { return [self leftmostDescendantOf: [node right]]; }
+
+
+- (Node *) nearDescendantOf: (Node *) node {
+ return [node left] ?
+ [self nearestLowerDescendantOf: node] :
+ [self nearestHigherDescendantOf: node];
+}
+
+
+// rolls the node once to the specified side. returns the node that was rolled into place instead
+// of the original node.
+- (Node *) rollNode: (Node *) node onceToSide: (ODSide) aSide {
+ ODSide otherSide = 1 - aSide;
+ int dir = DIR(aSide);
+ Node *parent = [node parent];
+
+ NSAssert([node childAtSide: otherSide], @"Did not find a node to roll");
+
+ // newTop will come up on top after the roll
+ Node *newTop = [node childAtSide: otherSide];
+
+ if (parent) { [parent setChild: newTop atSide: [parent sideOfChild: node]]; }
+ else { root = newTop; [newTop setParent: nil]; }
+
+ [node setChild: [newTop childAtSide: aSide] atSide: otherSide];
+ [newTop setChild: node atSide: aSide];
+
+ // update the node balances
+ node.balance += dir * (1 + max(0, -dir * newTop.balance));
+ newTop.balance += dir * (1 + max(0, dir * node.balance));
+
+ return newTop;
+}
+
+
+// rolls the node to the specified side. also rolls the rolled child if needed to minimize the
+// height of the tree.
+- (Node *) rollNode: (Node *) node toSide: (ODSide) aSide {
+ ODSide otherSide = 1 - aSide;
+ Node *newTop = [node childAtSide: otherSide];
+
+ // if needed, roll the rolled child node to minimize the height of the tree
+ if (DIR(aSide) * [newTop balance] > 0) {
+ [self rollNode: newTop onceToSide: otherSide];
+ }
+
+ // roll the specified node and return the node that was rolled in to replace it
+ return [self rollNode: node onceToSide: aSide];
+}
+
+
+// recursively updates the ancestor chain of the specified node to a change in the height of one
+// of its children. O(log n)
+- (void) updateNode: (Node *) node toHeightChange: (int) heightChange atSide: (ODSide) aSide {
+ int dir = DIR(aSide);
+ Node *rolledNode = node;
+ Node *originalParent = [node parent];
+ int parentHeightChange = 0;
+
+ // update the node's balance. the tree underneath the node should now be correctly balanced.
+ node.balance += dir * heightChange;
+ int balance = node.balance;
+
+ // if the node is out of balance, roll it
+ if (abs(balance) > 1) {
+ ODSide rollSide = (balance > 0) ? odLeft : odRight;
+ rolledNode = [self rollNode: node toSide: rollSide];
+ parentHeightChange = DIR(rollSide) * [[rolledNode childAtSide: rollSide] balance] >= 0 ?
+ min(heightChange, 0) :
+ 0;
+ }
+ // figure out if the node's height has changed
+ else if ((dir * balance > 0) && (heightChange > 0)) { parentHeightChange = 1; }
+ else if ((dir * balance >= 0) && (heightChange < 0)) { parentHeightChange = -1; }
+
+ // if the node's height has changed, recursively update the node's parent
+ if (originalParent && (parentHeightChange != 0)) {
+ [self updateNode: originalParent
+ toHeightChange: parentHeightChange
+ atSide: [originalParent sideOfChild: rolledNode]];
+ }
+}
+
+
+// public methods
+
+- (BOOL) containsKey: (id) aKey { return [self findNodeWithKey: aKey orNearest: NO] != nil; }
+- (id) objectForKey: (id) aKey { return [[self findNodeWithKey: aKey orNearest: NO] value]; }
+
+// enumerators
+- (NSEnumerator *) entryEnumerator { return [[EntryEnumerator alloc] initGoingForwardFromNode: [self leftmostDescendantOf: root]]; }
+- (NSEnumerator *) reverseEntryEnumerator { return [[EntryEnumerator alloc] initGoingBackFromNode: [self rightmostDescendantOf: root]]; }
+
+
+- (void) setObject: (id) anObject forKey: (id) aKey {
+ // tree empty? -- create first node and return -- O(1)
+ if (!root) {
+ NSAssert(count == 0, @"Expected a zero count when there is no root node");
+ root = [[Node alloc] initWithKey: aKey value: anObject andParent: nil];
+ count = 1;
+ return;
+ }
+
+ // node with key already in tree? -- update its value and return -- O(log n)
+ Node *node = [self findNodeWithKey: aKey orNearest: YES];
+ if ([aKey isEqual: [node key]]) {
+ [node setValue: anObject];
+ return;
+ }
+
+ // create a new node and add it as a child of the nearest node
+ ODSide side = ([aKey compare: [node key]] == NSOrderedAscending) ? odLeft : odRight;
+ Node *newNode = [[Node alloc] initWithKey: aKey value: anObject andParent: node];
+
+ [node setChild: newNode atSide: side];
+ node.balance += DIR(side);
+
+ // update the chain of ancestors about the height change
+ Node *parent = [node parent];
+ if (parent && ![node childAtSide: 1 - side]) {
+ [self updateNode: parent toHeightChange: 1 atSide: [parent sideOfChild: node]];
+ }
+
+ // update the cached entry count
+ ++count;
+}
+
+
+- (void) removeAllObjects {
+ //[root release];
+ root = nil;
+ count = 0;
+}
+
+
+- (void) removeObjectForKey: (id) aKey {
+ if (!root) { return; }
+
+ // find the node to remove; exit if not found -- O(log n)
+ Node *nodeToRemove = [self findNodeWithKey: aKey orNearest: NO];
+ if (!nodeToRemove) { return; }
+
+ // replace the key/value content of the node with that of its nearest descendant -- O(1)
+ Node *nearestDescendant = [self nearDescendantOf: nodeToRemove];
+ if (nearestDescendant) {
+ [nodeToRemove copyContentFromNode: nearestDescendant];
+ nodeToRemove = nearestDescendant;
+ }
+
+ // find the node's one child -- O(1)
+ Node *replacement = [nodeToRemove liveChild];
+
+ // remove the node from the tree -- O(log n)
+ if (![nodeToRemove parent]) {
+ root = replacement;
+ }
+ else {
+ // remove the node -- O(1)
+ Node *parent = [nodeToRemove parent];
+ ODSide sideAtParent = [parent sideOfChild: nodeToRemove];
+ [parent setChild: replacement atSide: sideAtParent];
+
+ // update the chain of anscesors about the change in height -- O(log n)
+ [self updateNode: parent toHeightChange: -1 atSide: sideAtParent];
+ }
+
+ // release the node -- O(1)
+ [nodeToRemove setChild: nil atSide: odLeft];
+ [nodeToRemove setChild: nil atSide: odRight];
+ //[nodeToRemove release];
+
+ // update the cached entry count
+ --count;
+}
+
+
+- (NSString *) description {
+ return [NSString stringWithFormat: @"{%@ count=%d\n root=%@\n}",
+ [super description],
+ count,
+ [root descriptionWithChildrenAndIndent: 1]];
+}
+
+
+// NSCoding protocol implementation
+
+- (void) encodeWithCoder: (NSCoder *) encoder {
+ [encoder encodeObject: root forKey: @"Root"];
+ [encoder encodeInteger: count forKey: @"Count"];
+}
+
+
+- (id) initWithCoder: (NSCoder *) decoder {
+ if (self = [super init]) {
+ root = [decoder decodeObjectForKey: @"Root"];//[[decoder decodeObjectForKey: @"Root"] retain];
+ count = [decoder decodeIntegerForKey: @"Count"];
+ }
+ return self;
+}
+
+
+// NSCopying protocol implementation
+
+- (id) copyWithZone: (NSZone *) zone {
+ return [[AvlTree alloc] initWithNode: [root copy] andCount: count];
+}
+
+
+@end
View
53 AQAppStateMachine/SortedDictionary/Internal/Enumerators/.svn/all-wcprops
@@ -0,0 +1,53 @@
+K 25
+svn:wc:ra_dav:version-url
+V 59
+/svn/!svn/ver/2/trunk/SortedDictionary/Internal/Enumerators
+END
+EntryEnumerator+Private.h
+K 25
+svn:wc:ra_dav:version-url
+V 85
+/svn/!svn/ver/2/trunk/SortedDictionary/Internal/Enumerators/EntryEnumerator+Private.h
+END
+KeyEnumerator.h
+K 25
+svn:wc:ra_dav:version-url
+V 75
+/svn/!svn/ver/2/trunk/SortedDictionary/Internal/Enumerators/KeyEnumerator.h
+END
+ObjectEnumerator.m
+K 25
+svn:wc:ra_dav:version-url
+V 78
+/svn/!svn/ver/2/trunk/SortedDictionary/Internal/Enumerators/ObjectEnumerator.m
+END
+EntryEnumerator+Private.m
+K 25
+svn:wc:ra_dav:version-url
+V 85
+/svn/!svn/ver/2/trunk/SortedDictionary/Internal/Enumerators/EntryEnumerator+Private.m
+END
+KeyEnumerator.m
+K 25
+svn:wc:ra_dav:version-url
+V 75
+/svn/!svn/ver/2/trunk/SortedDictionary/Internal/Enumerators/KeyEnumerator.m
+END
+EntryEnumerator.h
+K 25
+svn:wc:ra_dav:version-url
+V 77
+/svn/!svn/ver/2/trunk/SortedDictionary/Internal/Enumerators/EntryEnumerator.h
+END
+EntryEnumerator.m
+K 25
+svn:wc:ra_dav:version-url
+V 77
+/svn/!svn/ver/2/trunk/SortedDictionary/Internal/Enumerators/EntryEnumerator.m
+END
+ObjectEnumerator.h
+K 25
+svn:wc:ra_dav:version-url
+V 78
+/svn/!svn/ver/2/trunk/SortedDictionary/Internal/Enumerators/ObjectEnumerator.h
+END
View
124 AQAppStateMachine/SortedDictionary/Internal/Enumerators/.svn/entries
@@ -0,0 +1,124 @@
+8
+
+dir
+2
+https://orentrutner@cocoa-sorted-dictionary.googlecode.com/svn/trunk/SortedDictionary/Internal/Enumerators
+https://orentrutner@cocoa-sorted-dictionary.googlecode.com/svn
+
+
+
+2009-07-23T05:28:27.699070Z
+2
+orentrutner
+
+
+svn:special svn:externals svn:needs-lock
+
+
+
+
+
+
+
+
+
+
+
+4c890986-7748-11de-8e60-65c8b4fa459e
+
+EntryEnumerator+Private.h
+file
+
+
+
+
+2009-07-23T05:35:11.000000Z
+4d225e1be1fe65edcb294c7bd3f4fb4c
+2009-07-23T05:28:27.699070Z
+2
+orentrutner
+
+KeyEnumerator.h
+file
+
+
+
+
+2009-07-23T05:35:11.000000Z
+ca87bc93b22c6cb1df3c1c2539d1ae58
+2009-07-23T05:28:27.699070Z
+2
+orentrutner
+
+ObjectEnumerator.m
+file
+
+
+
+
+2009-07-23T05:35:11.000000Z
+7b578e5093e54ed1006e42fc504af1c3
+2009-07-23T05:28:27.699070Z
+2
+orentrutner
+
+EntryEnumerator+Private.m
+file
+
+
+
+
+2009-07-23T05:35:11.000000Z
+79105c6d84e507418663fbeac3fcad5d
+2009-07-23T05:28:27.699070Z
+2
+orentrutner
+
+KeyEnumerator.m
+file
+
+
+
+
+2009-07-23T05:35:11.000000Z
+5d7ad662c5bd84f73ca62afd3757a6d9
+2009-07-23T05:28:27.699070Z
+2
+orentrutner
+
+EntryEnumerator.h
+file
+
+
+
+
+2009-07-23T05:35:11.000000Z
+c3b72258bed4877da9fe74d97a8a7005
+2009-07-23T05:28:27.699070Z
+2
+orentrutner
+
+EntryEnumerator.m
+file
+
+
+
+
+2009-07-23T05:35:11.000000Z
+07dc88905742cc2d108d602506e1a01f
+2009-07-23T05:28:27.699070Z
+2
+orentrutner
+
+ObjectEnumerator.h
+file
+
+
+
+
+2009-07-23T05:35:11.000000Z
+d7d3ec3ccbe8f2a09b7fa87c61725f0d
+2009-07-23T05:28:27.699070Z
+2
+orentrutner
+
View
1 AQAppStateMachine/SortedDictionary/Internal/Enumerators/.svn/format
@@ -0,0 +1 @@
+8
View
9 ...e/SortedDictionary/Internal/Enumerators/.svn/text-base/EntryEnumerator+Private.h.svn-base
@@ -0,0 +1,9 @@
+#import <EntryEnumerator.h>
+
+
+@interface EntryEnumerator (Private)
+
+ - (id) initGoingForwardFromNode: (Node *) aNode;
+ - (id) initGoingBackFromNode: (Node *) aNode;
+
+@end
View
28 ...e/SortedDictionary/Internal/Enumerators/.svn/text-base/EntryEnumerator+Private.m.svn-base
@@ -0,0 +1,28 @@
+#import "EntryEnumerator+Private.h"
+#import "Node.h"
+
+
+@implementation EntryEnumerator (Private)
+
+
+- (id) initGoingForwardFromNode: (Node *) aNode {
+ if (self = [super init]) {
+ node = aNode;
+ first = @selector(left);
+ second = @selector(right);
+ }
+ return self;
+}
+
+
+- (id) initGoingBackFromNode: (Node *) aNode {
+ if (self = [super init]) {
+ node = aNode;
+ first = @selector(right);
+ second = @selector(left);
+ }
+ return self;
+}
+
+
+@end
View
17 ...teMachine/SortedDictionary/Internal/Enumerators/.svn/text-base/EntryEnumerator.h.svn-base
@@ -0,0 +1,17 @@
+#import <Cocoa/Cocoa.h>
+#import "SortedDictionaryEntry.h"
+
+
+@class Node;
+
+
+@interface EntryEnumerator : NSEnumerator {
+ Node *node;
+ SEL first;
+ SEL second;
+ }
+
+ - (NSArray *) allObjects;
+ - (id) nextObject;
+
+@end
View
48 ...teMachine/SortedDictionary/Internal/Enumerators/.svn/text-base/EntryEnumerator.m.svn-base
@@ -0,0 +1,48 @@
+#import "EntryEnumerator.h"
+#import "Node.h"
+
+
+@implementation EntryEnumerator
+
+
+- (NSArray *) allObjects {
+ NSMutableArray *objects = [[[NSMutableArray alloc] init] autorelease];
+
+ id object;
+ while (object = [self nextObject]) {
+ [objects addObject: object];
+ }
+
+ return objects;
+}
+
+
+- (id) nextObject {
+ // always return the node the enumerator is currently pointing at
+ if (!node) return nil;
+ Node *nodeToReturn = node;
+
+ // now move the enumerator's node to the following node...
+
+ // ...look for the next larger descendant, if there is one... (or smaller, if going back)
+ Node *nextNode = [node performSelector: second];
+ if (nextNode) {
+ node = nextNode;
+ while (nextNode = [node performSelector: first]) { node = nextNode; }
+ }
+
+ // ...or scan for the next unenumerated parent otherwise.
+ else {
+ Node *prevNode = node;
+ node = [node parent];
+ while (node && (prevNode == [node performSelector: second])) {
+ prevNode = node;
+ node = [node parent];
+ }
+ }
+
+ return nodeToReturn;
+}
+
+
+@end
View
16 ...tateMachine/SortedDictionary/Internal/Enumerators/.svn/text-base/KeyEnumerator.h.svn-base
@@ -0,0 +1,16 @@
+#import <Cocoa/Cocoa.h>
+
+
+@class EntryEnumerator;
+
+
+@interface KeyEnumerator : NSEnumerator {
+ EntryEnumerator *entryEnum;
+ }
+
+ - (id) initWithEnumerator: (NSEnumerator *) anEnumerator;
+
+ - (NSArray *) allObjects;
+ - (id) nextObject;
+
+@end
View
39 ...tateMachine/SortedDictionary/Internal/Enumerators/.svn/text-base/KeyEnumerator.m.svn-base
@@ -0,0 +1,39 @@
+#import "KeyEnumerator.h"
+#import "EntryEnumerator.h"
+
+
+@implementation KeyEnumerator
+
+
+- (id) initWithEnumerator: (NSEnumerator *) anEnumerator {
+ if (self = [super init]) {
+ entryEnum = (EntryEnumerator *) [anEnumerator retain];
+ }
+ return self;
+}
+
+
+- (NSArray *) allObjects {
+ NSMutableArray *objects = [[[NSMutableArray alloc] init] autorelease];
+
+ id object = nil;
+ while (object = [self nextObject]) {
+ [objects addObject: object];
+ }
+
+ return objects;
+}
+
+
+- (id) nextObject {
+ return [[entryEnum nextObject] key];
+}
+
+
+- (void) dealloc {
+ [entryEnum release];
+ [super dealloc];
+}
+
+
+@end
View
16 ...eMachine/SortedDictionary/Internal/Enumerators/.svn/text-base/ObjectEnumerator.h.svn-base
@@ -0,0 +1,16 @@
+#import <Cocoa/Cocoa.h>
+