├── .gitignore ├── Algorithm.xcworkspace └── contents.xcworkspacedata ├── ConvexHull ├── ConvexHull.xcodeproj │ └── project.pbxproj ├── ConvexHull │ ├── AppDelegate.swift │ ├── Background.swift │ ├── Base.lproj │ │ └── Main.storyboard │ ├── BruteForceCH.swift │ ├── DivideAndConquer.swift │ ├── GrahamScan.swift │ ├── HelpMethod.swift │ ├── Images.xcassets │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ ├── RedPoint.imageset │ │ │ ├── Contents.json │ │ │ └── RedPoint.png │ │ └── point.imageset │ │ │ ├── Contents.json │ │ │ └── point.png │ ├── Info.plist │ ├── PointView.swift │ └── ViewController.swift └── ConvexHullTests │ ├── ConvexHullTests.swift │ └── Info.plist ├── DBASortLink ├── DBASortLink.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata ├── DBASortLink │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Base.lproj │ │ └── Main.storyboard │ ├── DataFactory.h │ ├── DataFactory.m │ ├── DataLinker.h │ ├── DataLinker.m │ ├── DataSorter.h │ ├── DataSorter.m │ ├── Images.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Info.plist │ ├── ViewController.h │ ├── ViewController.m │ └── main.m └── DBASortLinkTests │ ├── DBASortLinkTests.m │ └── Info.plist ├── Hamiltonian ├── Hamiltonian.xcodeproj │ └── project.pbxproj ├── Hamiltonian │ ├── AppDelegate.swift │ ├── Background.swift │ ├── Base.lproj │ │ └── Main.storyboard │ ├── BaseTreeSearching.swift │ ├── HelpMethod.swift │ ├── HillClimbingSearch.swift │ ├── Images.xcassets │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ ├── RedPoint.imageset │ │ │ ├── Contents.json │ │ │ └── RedPoint.png │ │ └── point.imageset │ │ │ ├── Contents.json │ │ │ └── point.png │ ├── Info.plist │ ├── MySearching.swift │ ├── PointView.swift │ └── ViewController.swift └── HamiltonianTests │ ├── HamiltonianTests.swift │ └── Info.plist ├── LCS ├── LCS.xcodeproj │ └── project.pbxproj ├── LCS │ ├── AppDelegate.swift │ ├── Background.swift │ ├── Base.lproj │ │ └── Main.storyboard │ ├── Images.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Info.plist │ ├── LCS.swift │ └── ViewController.swift └── LCSTests │ ├── Info.plist │ └── LCSTests.swift ├── N-Queen ├── N-Queen.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata └── N-Queen │ └── main.cpp └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | *.xccheckout 14 | *.moved-aside 15 | DerivedData 16 | *.hmap 17 | *.ipa 18 | *.xcuserstate 19 | 20 | # CocoaPods 21 | # 22 | # We recommend against adding the Pods directory to your .gitignore. However 23 | # you should judge for yourself, the pros and cons are mentioned at: 24 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 25 | # 26 | # Pods/ -------------------------------------------------------------------------------- /Algorithm.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 12 | 13 | 15 | 16 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /ConvexHull/ConvexHull.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | A412370B1A24A6F0006FDBB8 /* DivideAndConquer.swift in Sources */ = {isa = PBXBuildFile; fileRef = A412370A1A24A6F0006FDBB8 /* DivideAndConquer.swift */; }; 11 | A41388BD1A2363EA00B14710 /* Background.swift in Sources */ = {isa = PBXBuildFile; fileRef = A41388BC1A2363EA00B14710 /* Background.swift */; }; 12 | A41885EC1A23047300829E0B /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = A41885EB1A23047300829E0B /* AppDelegate.swift */; }; 13 | A41885EE1A23047300829E0B /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A41885ED1A23047300829E0B /* ViewController.swift */; }; 14 | A41885F01A23047300829E0B /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A41885EF1A23047300829E0B /* Images.xcassets */; }; 15 | A41885F31A23047300829E0B /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A41885F11A23047300829E0B /* Main.storyboard */; }; 16 | A41885FF1A23047300829E0B /* ConvexHullTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A41885FE1A23047300829E0B /* ConvexHullTests.swift */; }; 17 | A41886091A2304F900829E0B /* BruteForceCH.swift in Sources */ = {isa = PBXBuildFile; fileRef = A41886081A2304F900829E0B /* BruteForceCH.swift */; }; 18 | A41EF85E1A240D4F0014A61F /* PointView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A41EF85D1A240D4F0014A61F /* PointView.swift */; }; 19 | A42800461A241ACF00F28C78 /* HelpMethod.swift in Sources */ = {isa = PBXBuildFile; fileRef = A42800451A241ACF00F28C78 /* HelpMethod.swift */; }; 20 | A42800491A2464F800F28C78 /* GrahamScan.swift in Sources */ = {isa = PBXBuildFile; fileRef = A42800481A2464F800F28C78 /* GrahamScan.swift */; }; 21 | /* End PBXBuildFile section */ 22 | 23 | /* Begin PBXContainerItemProxy section */ 24 | A41885F91A23047300829E0B /* PBXContainerItemProxy */ = { 25 | isa = PBXContainerItemProxy; 26 | containerPortal = A41885DE1A23047300829E0B /* Project object */; 27 | proxyType = 1; 28 | remoteGlobalIDString = A41885E51A23047300829E0B; 29 | remoteInfo = ConvexHull; 30 | }; 31 | /* End PBXContainerItemProxy section */ 32 | 33 | /* Begin PBXFileReference section */ 34 | A412370A1A24A6F0006FDBB8 /* DivideAndConquer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DivideAndConquer.swift; sourceTree = ""; }; 35 | A41388BC1A2363EA00B14710 /* Background.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Background.swift; sourceTree = ""; }; 36 | A41885E61A23047300829E0B /* ConvexHull.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ConvexHull.app; sourceTree = BUILT_PRODUCTS_DIR; }; 37 | A41885EA1A23047300829E0B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 38 | A41885EB1A23047300829E0B /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 39 | A41885ED1A23047300829E0B /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 40 | A41885EF1A23047300829E0B /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 41 | A41885F21A23047300829E0B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 42 | A41885F81A23047300829E0B /* ConvexHullTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ConvexHullTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 43 | A41885FD1A23047300829E0B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 44 | A41885FE1A23047300829E0B /* ConvexHullTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConvexHullTests.swift; sourceTree = ""; }; 45 | A41886081A2304F900829E0B /* BruteForceCH.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BruteForceCH.swift; sourceTree = ""; }; 46 | A41EF85D1A240D4F0014A61F /* PointView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PointView.swift; sourceTree = ""; }; 47 | A42800451A241ACF00F28C78 /* HelpMethod.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HelpMethod.swift; sourceTree = ""; }; 48 | A42800481A2464F800F28C78 /* GrahamScan.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GrahamScan.swift; sourceTree = ""; }; 49 | /* End PBXFileReference section */ 50 | 51 | /* Begin PBXFrameworksBuildPhase section */ 52 | A41885E31A23047300829E0B /* Frameworks */ = { 53 | isa = PBXFrameworksBuildPhase; 54 | buildActionMask = 2147483647; 55 | files = ( 56 | ); 57 | runOnlyForDeploymentPostprocessing = 0; 58 | }; 59 | A41885F51A23047300829E0B /* Frameworks */ = { 60 | isa = PBXFrameworksBuildPhase; 61 | buildActionMask = 2147483647; 62 | files = ( 63 | ); 64 | runOnlyForDeploymentPostprocessing = 0; 65 | }; 66 | /* End PBXFrameworksBuildPhase section */ 67 | 68 | /* Begin PBXGroup section */ 69 | A41885DD1A23047300829E0B = { 70 | isa = PBXGroup; 71 | children = ( 72 | A41885E81A23047300829E0B /* ConvexHull */, 73 | A41885FB1A23047300829E0B /* ConvexHullTests */, 74 | A41885E71A23047300829E0B /* Products */, 75 | ); 76 | sourceTree = ""; 77 | }; 78 | A41885E71A23047300829E0B /* Products */ = { 79 | isa = PBXGroup; 80 | children = ( 81 | A41885E61A23047300829E0B /* ConvexHull.app */, 82 | A41885F81A23047300829E0B /* ConvexHullTests.xctest */, 83 | ); 84 | name = Products; 85 | sourceTree = ""; 86 | }; 87 | A41885E81A23047300829E0B /* ConvexHull */ = { 88 | isa = PBXGroup; 89 | children = ( 90 | A42800471A241AD600F28C78 /* Utils */, 91 | A41EF8601A240D6A0014A61F /* Algorithm */, 92 | A41EF85F1A240D590014A61F /* Views */, 93 | A41885EB1A23047300829E0B /* AppDelegate.swift */, 94 | A41885ED1A23047300829E0B /* ViewController.swift */, 95 | A41885EF1A23047300829E0B /* Images.xcassets */, 96 | A41885F11A23047300829E0B /* Main.storyboard */, 97 | A41885E91A23047300829E0B /* Supporting Files */, 98 | ); 99 | path = ConvexHull; 100 | sourceTree = ""; 101 | }; 102 | A41885E91A23047300829E0B /* Supporting Files */ = { 103 | isa = PBXGroup; 104 | children = ( 105 | A41885EA1A23047300829E0B /* Info.plist */, 106 | ); 107 | name = "Supporting Files"; 108 | sourceTree = ""; 109 | }; 110 | A41885FB1A23047300829E0B /* ConvexHullTests */ = { 111 | isa = PBXGroup; 112 | children = ( 113 | A41885FE1A23047300829E0B /* ConvexHullTests.swift */, 114 | A41885FC1A23047300829E0B /* Supporting Files */, 115 | ); 116 | path = ConvexHullTests; 117 | sourceTree = ""; 118 | }; 119 | A41885FC1A23047300829E0B /* Supporting Files */ = { 120 | isa = PBXGroup; 121 | children = ( 122 | A41885FD1A23047300829E0B /* Info.plist */, 123 | ); 124 | name = "Supporting Files"; 125 | sourceTree = ""; 126 | }; 127 | A41EF85F1A240D590014A61F /* Views */ = { 128 | isa = PBXGroup; 129 | children = ( 130 | A41388BC1A2363EA00B14710 /* Background.swift */, 131 | A41EF85D1A240D4F0014A61F /* PointView.swift */, 132 | ); 133 | name = Views; 134 | sourceTree = ""; 135 | }; 136 | A41EF8601A240D6A0014A61F /* Algorithm */ = { 137 | isa = PBXGroup; 138 | children = ( 139 | A41886081A2304F900829E0B /* BruteForceCH.swift */, 140 | A42800481A2464F800F28C78 /* GrahamScan.swift */, 141 | A412370A1A24A6F0006FDBB8 /* DivideAndConquer.swift */, 142 | ); 143 | name = Algorithm; 144 | sourceTree = ""; 145 | }; 146 | A42800471A241AD600F28C78 /* Utils */ = { 147 | isa = PBXGroup; 148 | children = ( 149 | A42800451A241ACF00F28C78 /* HelpMethod.swift */, 150 | ); 151 | name = Utils; 152 | sourceTree = ""; 153 | }; 154 | /* End PBXGroup section */ 155 | 156 | /* Begin PBXNativeTarget section */ 157 | A41885E51A23047300829E0B /* ConvexHull */ = { 158 | isa = PBXNativeTarget; 159 | buildConfigurationList = A41886021A23047300829E0B /* Build configuration list for PBXNativeTarget "ConvexHull" */; 160 | buildPhases = ( 161 | A41885E21A23047300829E0B /* Sources */, 162 | A41885E31A23047300829E0B /* Frameworks */, 163 | A41885E41A23047300829E0B /* Resources */, 164 | ); 165 | buildRules = ( 166 | ); 167 | dependencies = ( 168 | ); 169 | name = ConvexHull; 170 | productName = ConvexHull; 171 | productReference = A41885E61A23047300829E0B /* ConvexHull.app */; 172 | productType = "com.apple.product-type.application"; 173 | }; 174 | A41885F71A23047300829E0B /* ConvexHullTests */ = { 175 | isa = PBXNativeTarget; 176 | buildConfigurationList = A41886051A23047300829E0B /* Build configuration list for PBXNativeTarget "ConvexHullTests" */; 177 | buildPhases = ( 178 | A41885F41A23047300829E0B /* Sources */, 179 | A41885F51A23047300829E0B /* Frameworks */, 180 | A41885F61A23047300829E0B /* Resources */, 181 | ); 182 | buildRules = ( 183 | ); 184 | dependencies = ( 185 | A41885FA1A23047300829E0B /* PBXTargetDependency */, 186 | ); 187 | name = ConvexHullTests; 188 | productName = ConvexHullTests; 189 | productReference = A41885F81A23047300829E0B /* ConvexHullTests.xctest */; 190 | productType = "com.apple.product-type.bundle.unit-test"; 191 | }; 192 | /* End PBXNativeTarget section */ 193 | 194 | /* Begin PBXProject section */ 195 | A41885DE1A23047300829E0B /* Project object */ = { 196 | isa = PBXProject; 197 | attributes = { 198 | LastSwiftMigration = 0700; 199 | LastSwiftUpdateCheck = 0700; 200 | LastUpgradeCheck = 0800; 201 | ORGANIZATIONNAME = "杨萧玉"; 202 | TargetAttributes = { 203 | A41885E51A23047300829E0B = { 204 | CreatedOnToolsVersion = 6.1; 205 | LastSwiftMigration = 0800; 206 | }; 207 | A41885F71A23047300829E0B = { 208 | CreatedOnToolsVersion = 6.1; 209 | LastSwiftMigration = 0800; 210 | TestTargetID = A41885E51A23047300829E0B; 211 | }; 212 | }; 213 | }; 214 | buildConfigurationList = A41885E11A23047300829E0B /* Build configuration list for PBXProject "ConvexHull" */; 215 | compatibilityVersion = "Xcode 3.2"; 216 | developmentRegion = English; 217 | hasScannedForEncodings = 0; 218 | knownRegions = ( 219 | en, 220 | Base, 221 | ); 222 | mainGroup = A41885DD1A23047300829E0B; 223 | productRefGroup = A41885E71A23047300829E0B /* Products */; 224 | projectDirPath = ""; 225 | projectRoot = ""; 226 | targets = ( 227 | A41885E51A23047300829E0B /* ConvexHull */, 228 | A41885F71A23047300829E0B /* ConvexHullTests */, 229 | ); 230 | }; 231 | /* End PBXProject section */ 232 | 233 | /* Begin PBXResourcesBuildPhase section */ 234 | A41885E41A23047300829E0B /* Resources */ = { 235 | isa = PBXResourcesBuildPhase; 236 | buildActionMask = 2147483647; 237 | files = ( 238 | A41885F01A23047300829E0B /* Images.xcassets in Resources */, 239 | A41885F31A23047300829E0B /* Main.storyboard in Resources */, 240 | ); 241 | runOnlyForDeploymentPostprocessing = 0; 242 | }; 243 | A41885F61A23047300829E0B /* Resources */ = { 244 | isa = PBXResourcesBuildPhase; 245 | buildActionMask = 2147483647; 246 | files = ( 247 | ); 248 | runOnlyForDeploymentPostprocessing = 0; 249 | }; 250 | /* End PBXResourcesBuildPhase section */ 251 | 252 | /* Begin PBXSourcesBuildPhase section */ 253 | A41885E21A23047300829E0B /* Sources */ = { 254 | isa = PBXSourcesBuildPhase; 255 | buildActionMask = 2147483647; 256 | files = ( 257 | A41EF85E1A240D4F0014A61F /* PointView.swift in Sources */, 258 | A42800461A241ACF00F28C78 /* HelpMethod.swift in Sources */, 259 | A42800491A2464F800F28C78 /* GrahamScan.swift in Sources */, 260 | A41885EE1A23047300829E0B /* ViewController.swift in Sources */, 261 | A41885EC1A23047300829E0B /* AppDelegate.swift in Sources */, 262 | A41886091A2304F900829E0B /* BruteForceCH.swift in Sources */, 263 | A412370B1A24A6F0006FDBB8 /* DivideAndConquer.swift in Sources */, 264 | A41388BD1A2363EA00B14710 /* Background.swift in Sources */, 265 | ); 266 | runOnlyForDeploymentPostprocessing = 0; 267 | }; 268 | A41885F41A23047300829E0B /* Sources */ = { 269 | isa = PBXSourcesBuildPhase; 270 | buildActionMask = 2147483647; 271 | files = ( 272 | A41885FF1A23047300829E0B /* ConvexHullTests.swift in Sources */, 273 | ); 274 | runOnlyForDeploymentPostprocessing = 0; 275 | }; 276 | /* End PBXSourcesBuildPhase section */ 277 | 278 | /* Begin PBXTargetDependency section */ 279 | A41885FA1A23047300829E0B /* PBXTargetDependency */ = { 280 | isa = PBXTargetDependency; 281 | target = A41885E51A23047300829E0B /* ConvexHull */; 282 | targetProxy = A41885F91A23047300829E0B /* PBXContainerItemProxy */; 283 | }; 284 | /* End PBXTargetDependency section */ 285 | 286 | /* Begin PBXVariantGroup section */ 287 | A41885F11A23047300829E0B /* Main.storyboard */ = { 288 | isa = PBXVariantGroup; 289 | children = ( 290 | A41885F21A23047300829E0B /* Base */, 291 | ); 292 | name = Main.storyboard; 293 | sourceTree = ""; 294 | }; 295 | /* End PBXVariantGroup section */ 296 | 297 | /* Begin XCBuildConfiguration section */ 298 | A41886001A23047300829E0B /* Debug */ = { 299 | isa = XCBuildConfiguration; 300 | buildSettings = { 301 | ALWAYS_SEARCH_USER_PATHS = NO; 302 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 303 | CLANG_CXX_LIBRARY = "libc++"; 304 | CLANG_ENABLE_MODULES = YES; 305 | CLANG_ENABLE_OBJC_ARC = YES; 306 | CLANG_WARN_BOOL_CONVERSION = YES; 307 | CLANG_WARN_CONSTANT_CONVERSION = YES; 308 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 309 | CLANG_WARN_EMPTY_BODY = YES; 310 | CLANG_WARN_ENUM_CONVERSION = YES; 311 | CLANG_WARN_INFINITE_RECURSION = YES; 312 | CLANG_WARN_INT_CONVERSION = YES; 313 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 314 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 315 | CLANG_WARN_UNREACHABLE_CODE = YES; 316 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 317 | CODE_SIGN_IDENTITY = "-"; 318 | COPY_PHASE_STRIP = NO; 319 | ENABLE_STRICT_OBJC_MSGSEND = YES; 320 | ENABLE_TESTABILITY = YES; 321 | GCC_C_LANGUAGE_STANDARD = gnu99; 322 | GCC_DYNAMIC_NO_PIC = NO; 323 | GCC_NO_COMMON_BLOCKS = YES; 324 | GCC_OPTIMIZATION_LEVEL = 0; 325 | GCC_PREPROCESSOR_DEFINITIONS = ( 326 | "DEBUG=1", 327 | "$(inherited)", 328 | ); 329 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 330 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 331 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 332 | GCC_WARN_UNDECLARED_SELECTOR = YES; 333 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 334 | GCC_WARN_UNUSED_FUNCTION = YES; 335 | GCC_WARN_UNUSED_VARIABLE = YES; 336 | MACOSX_DEPLOYMENT_TARGET = 10.10; 337 | MTL_ENABLE_DEBUG_INFO = YES; 338 | ONLY_ACTIVE_ARCH = YES; 339 | SDKROOT = macosx; 340 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 341 | }; 342 | name = Debug; 343 | }; 344 | A41886011A23047300829E0B /* Release */ = { 345 | isa = XCBuildConfiguration; 346 | buildSettings = { 347 | ALWAYS_SEARCH_USER_PATHS = NO; 348 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 349 | CLANG_CXX_LIBRARY = "libc++"; 350 | CLANG_ENABLE_MODULES = YES; 351 | CLANG_ENABLE_OBJC_ARC = YES; 352 | CLANG_WARN_BOOL_CONVERSION = YES; 353 | CLANG_WARN_CONSTANT_CONVERSION = YES; 354 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 355 | CLANG_WARN_EMPTY_BODY = YES; 356 | CLANG_WARN_ENUM_CONVERSION = YES; 357 | CLANG_WARN_INFINITE_RECURSION = YES; 358 | CLANG_WARN_INT_CONVERSION = YES; 359 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 360 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 361 | CLANG_WARN_UNREACHABLE_CODE = YES; 362 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 363 | CODE_SIGN_IDENTITY = "-"; 364 | COPY_PHASE_STRIP = YES; 365 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 366 | ENABLE_NS_ASSERTIONS = NO; 367 | ENABLE_STRICT_OBJC_MSGSEND = YES; 368 | GCC_C_LANGUAGE_STANDARD = gnu99; 369 | GCC_NO_COMMON_BLOCKS = YES; 370 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 371 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 372 | GCC_WARN_UNDECLARED_SELECTOR = YES; 373 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 374 | GCC_WARN_UNUSED_FUNCTION = YES; 375 | GCC_WARN_UNUSED_VARIABLE = YES; 376 | MACOSX_DEPLOYMENT_TARGET = 10.10; 377 | MTL_ENABLE_DEBUG_INFO = NO; 378 | SDKROOT = macosx; 379 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 380 | }; 381 | name = Release; 382 | }; 383 | A41886031A23047300829E0B /* Debug */ = { 384 | isa = XCBuildConfiguration; 385 | buildSettings = { 386 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 387 | COMBINE_HIDPI_IMAGES = YES; 388 | INFOPLIST_FILE = ConvexHull/Info.plist; 389 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; 390 | PRODUCT_BUNDLE_IDENTIFIER = "com.yxy.$(PRODUCT_NAME:rfc1034identifier)"; 391 | PRODUCT_NAME = "$(TARGET_NAME)"; 392 | SWIFT_VERSION = 3.0; 393 | }; 394 | name = Debug; 395 | }; 396 | A41886041A23047300829E0B /* Release */ = { 397 | isa = XCBuildConfiguration; 398 | buildSettings = { 399 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 400 | COMBINE_HIDPI_IMAGES = YES; 401 | INFOPLIST_FILE = ConvexHull/Info.plist; 402 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; 403 | PRODUCT_BUNDLE_IDENTIFIER = "com.yxy.$(PRODUCT_NAME:rfc1034identifier)"; 404 | PRODUCT_NAME = "$(TARGET_NAME)"; 405 | SWIFT_VERSION = 3.0; 406 | }; 407 | name = Release; 408 | }; 409 | A41886061A23047300829E0B /* Debug */ = { 410 | isa = XCBuildConfiguration; 411 | buildSettings = { 412 | BUNDLE_LOADER = "$(TEST_HOST)"; 413 | COMBINE_HIDPI_IMAGES = YES; 414 | FRAMEWORK_SEARCH_PATHS = ( 415 | "$(DEVELOPER_FRAMEWORKS_DIR)", 416 | "$(inherited)", 417 | ); 418 | GCC_PREPROCESSOR_DEFINITIONS = ( 419 | "DEBUG=1", 420 | "$(inherited)", 421 | ); 422 | INFOPLIST_FILE = ConvexHullTests/Info.plist; 423 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; 424 | PRODUCT_BUNDLE_IDENTIFIER = "com.yxy.$(PRODUCT_NAME:rfc1034identifier)"; 425 | PRODUCT_NAME = "$(TARGET_NAME)"; 426 | SWIFT_VERSION = 3.0; 427 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ConvexHull.app/Contents/MacOS/ConvexHull"; 428 | }; 429 | name = Debug; 430 | }; 431 | A41886071A23047300829E0B /* Release */ = { 432 | isa = XCBuildConfiguration; 433 | buildSettings = { 434 | BUNDLE_LOADER = "$(TEST_HOST)"; 435 | COMBINE_HIDPI_IMAGES = YES; 436 | FRAMEWORK_SEARCH_PATHS = ( 437 | "$(DEVELOPER_FRAMEWORKS_DIR)", 438 | "$(inherited)", 439 | ); 440 | INFOPLIST_FILE = ConvexHullTests/Info.plist; 441 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; 442 | PRODUCT_BUNDLE_IDENTIFIER = "com.yxy.$(PRODUCT_NAME:rfc1034identifier)"; 443 | PRODUCT_NAME = "$(TARGET_NAME)"; 444 | SWIFT_VERSION = 3.0; 445 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ConvexHull.app/Contents/MacOS/ConvexHull"; 446 | }; 447 | name = Release; 448 | }; 449 | /* End XCBuildConfiguration section */ 450 | 451 | /* Begin XCConfigurationList section */ 452 | A41885E11A23047300829E0B /* Build configuration list for PBXProject "ConvexHull" */ = { 453 | isa = XCConfigurationList; 454 | buildConfigurations = ( 455 | A41886001A23047300829E0B /* Debug */, 456 | A41886011A23047300829E0B /* Release */, 457 | ); 458 | defaultConfigurationIsVisible = 0; 459 | defaultConfigurationName = Release; 460 | }; 461 | A41886021A23047300829E0B /* Build configuration list for PBXNativeTarget "ConvexHull" */ = { 462 | isa = XCConfigurationList; 463 | buildConfigurations = ( 464 | A41886031A23047300829E0B /* Debug */, 465 | A41886041A23047300829E0B /* Release */, 466 | ); 467 | defaultConfigurationIsVisible = 0; 468 | defaultConfigurationName = Release; 469 | }; 470 | A41886051A23047300829E0B /* Build configuration list for PBXNativeTarget "ConvexHullTests" */ = { 471 | isa = XCConfigurationList; 472 | buildConfigurations = ( 473 | A41886061A23047300829E0B /* Debug */, 474 | A41886071A23047300829E0B /* Release */, 475 | ); 476 | defaultConfigurationIsVisible = 0; 477 | defaultConfigurationName = Release; 478 | }; 479 | /* End XCConfigurationList section */ 480 | }; 481 | rootObject = A41885DE1A23047300829E0B /* Project object */; 482 | } 483 | -------------------------------------------------------------------------------- /ConvexHull/ConvexHull/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // ConvexHull 4 | // 5 | // Created by 杨萧玉 on 14/11/24. 6 | // Copyright (c) 2014年 杨萧玉. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | import AppKit 11 | 12 | @NSApplicationMain 13 | class AppDelegate: NSObject, NSApplicationDelegate { 14 | 15 | var chooseDelegate:ChooseAlgorithm? 16 | 17 | func applicationDidFinishLaunching(_ aNotification: Notification) { 18 | // Insert code here to initialize your application 19 | } 20 | 21 | func applicationWillTerminate(_ aNotification: Notification) { 22 | // Insert code here to tear down your application 23 | } 24 | 25 | @IBAction func selectAlgorithm(_ sender: NSMenuItem) { 26 | switch sender.title { 27 | case "蛮力法": 28 | chooseDelegate?.algorithmSelected = .bruteForceCH 29 | case "GrahamScan": 30 | chooseDelegate?.algorithmSelected = .grahamScan 31 | case "DivideAndConquer": 32 | chooseDelegate?.algorithmSelected = .divideAndConquer 33 | default: 34 | chooseDelegate?.algorithmSelected = .grahamScan 35 | } 36 | } 37 | 38 | @IBAction func selectPointSum(_ sender: NSMenuItem) { 39 | switch sender.title { 40 | case "0": 41 | chooseDelegate?.pointNumSelected = 0 42 | case "1000": 43 | chooseDelegate?.pointNumSelected = 1000 44 | case "2000": 45 | chooseDelegate?.pointNumSelected = 2000 46 | case "3000": 47 | chooseDelegate?.pointNumSelected = 3000 48 | case let x: 49 | if let num = Int(x) { 50 | chooseDelegate?.pointNumSelected = UInt32(num) 51 | } 52 | } 53 | } 54 | 55 | 56 | } 57 | 58 | -------------------------------------------------------------------------------- /ConvexHull/ConvexHull/Background.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Background.swift 3 | // ConvexHull 4 | // 5 | // Created by 杨萧玉 on 14/11/24. 6 | // Copyright (c) 2014年 杨萧玉. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | import AppKit 11 | 12 | class Background: NSView, ChooseAlgorithm { 13 | 14 | @IBOutlet weak var costTimeLabel: NSTextField! 15 | var points:[PointView] = [] 16 | var generator:ConvexHullGenerator? 17 | var algorithmSelected:Algorithm = Algorithm.bruteForceCH { 18 | willSet{ 19 | switch newValue { 20 | case .bruteForceCH: 21 | generator = BruteForceCH() 22 | case .grahamScan: 23 | generator = GrahamScan() 24 | case .divideAndConquer: 25 | generator = DivideAndConquer() 26 | } 27 | makeConvexHull() 28 | } 29 | } 30 | var pointNumSelected:UInt32 = 0 { 31 | willSet{ 32 | createPointsWithNum(newValue) 33 | makeConvexHull() 34 | } 35 | } 36 | var size:CGSize! 37 | override func draw(_ dirtyRect: NSRect) { 38 | super.draw(dirtyRect) 39 | if points.isEmpty { 40 | return 41 | } 42 | 43 | let path = CGMutablePath() 44 | var locations:[CGPoint] = [] 45 | for point in points { 46 | if point.isConvexHullNode { 47 | locations.append(point.position) 48 | } 49 | } 50 | path.addLines(between: locations) 51 | if !locations.isEmpty { 52 | path.closeSubpath() 53 | } 54 | let context = NSGraphicsContext.current()?.cgContext 55 | context?.clear(NSRect(origin: CGPoint.zero, size: frame.size)) 56 | context?.addPath(path) 57 | context?.setLineJoin(CGLineJoin.round) 58 | context?.setLineWidth(5.0) 59 | NSColor.red.setStroke() 60 | context?.drawPath(using: CGPathDrawingMode.stroke) 61 | 62 | 63 | } 64 | 65 | override func viewWillMove(toWindow newWindow: NSWindow?) { 66 | super.viewWillMove(toWindow: newWindow) 67 | size = newWindow?.frame.size 68 | // generator = BruteForceCH() 69 | getAppDelegate().chooseDelegate = self 70 | } 71 | 72 | override func mouseUp(with theEvent: NSEvent) { 73 | if theEvent.clickCount > 1 { 74 | let location = convert(theEvent.locationInWindow, from: nil) 75 | addPont(location) 76 | makeConvexHull() 77 | } 78 | } 79 | 80 | func addPont(_ location:CGPoint) { 81 | let pointView = PointView(location: location) 82 | points.append(pointView) 83 | addSubview(pointView) 84 | } 85 | 86 | func clearPoints() { 87 | for point in points { 88 | point.removeFromSuperview() 89 | } 90 | points.removeAll(keepingCapacity: false) 91 | } 92 | 93 | func makeConvexHull() { 94 | generator?.generateConvexHull(&points) 95 | if let cost = generator?.costTime { 96 | (costTimeLabel.cell as! NSTextFieldCell).title = "\(cost*1000)" 97 | } 98 | else{ 99 | (costTimeLabel.cell as! NSTextFieldCell).title = "no" 100 | } 101 | setNeedsDisplay(frame) 102 | } 103 | 104 | 105 | func createPointsWithNum(_ num:UInt32) { 106 | clearPoints() 107 | for _ in 0.. maxXPoint.position.x ? point : maxXPoint 34 | } 35 | 36 | let point1 = minXPoint; 37 | for point2 in points { 38 | if !point2.isConvexHullNode || point2 == point1 { 39 | continue 40 | } 41 | for point3 in points { 42 | if !point3.isConvexHullNode || point3 == point1 || point3 == point2 { 43 | continue 44 | } 45 | for point4 in points { 46 | if !point4.isConvexHullNode || point4 == point1 || point4 == point2 || point4 == point3 { 47 | continue 48 | } 49 | if checkPoint(point4.position, inTriangle: (point2.position,point3.position,point1.position)) { 50 | point4.isConvexHullNode = false 51 | continue 52 | } 53 | } 54 | } 55 | } 56 | 57 | var su = points.filter { 58 | calculatePoint($0.position, onLine: (minXPoint.position,maxXPoint.position)) > 0 59 | } 60 | var sl = points.filter { 61 | calculatePoint($0.position, onLine: (minXPoint.position,maxXPoint.position)) < 0 62 | } 63 | su = su.sorted { 64 | return ($0.position as CGPoint).x > ($1.position as CGPoint).x 65 | } 66 | sl = sl.sorted { 67 | return ($0.position as CGPoint).x < ($1.position as CGPoint).x 68 | } 69 | var result = [minXPoint] 70 | result += sl 71 | result.append(maxXPoint) 72 | result += su 73 | points = result 74 | endTime = Date() 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /ConvexHull/ConvexHull/DivideAndConquer.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DivideAndConquer.swift 3 | // ConvexHull 4 | // 5 | // Created by 杨萧玉 on 14/11/25. 6 | // Copyright (c) 2014年 杨萧玉. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | import AppKit 11 | 12 | 13 | class DivideAndConquer: NSObject, ConvexHullGenerator { 14 | 15 | var restPoints = [PointView]() 16 | var beginTime = Date(timeIntervalSince1970: 0) 17 | var endTime = Date(timeIntervalSince1970: 0) 18 | var costTime:TimeInterval { 19 | get{ 20 | return endTime.timeIntervalSince(beginTime) 21 | } 22 | } 23 | func Conquer(_ points: inout [PointView]) { 24 | // println(points.count) 25 | if points.count < 3 { 26 | return 27 | } 28 | 29 | func midPoint(_ points:[PointView]) -> CGPoint? { 30 | if points.count == 1 { 31 | return nil 32 | } 33 | var minYPoint = points[0] 34 | var maxYPoint = points[0] 35 | 36 | for point in points { 37 | minYPoint = point.position.y < minYPoint.position.y ? point : minYPoint 38 | maxYPoint = point.position.y > maxYPoint.position.y ? point : maxYPoint 39 | } 40 | let midPoint = CGPoint(x:(minYPoint.position.x + maxYPoint.position.x)/2,y:(minYPoint.position.y + maxYPoint.position.y)/2) 41 | return midPoint 42 | } 43 | 44 | func counterclockwiseSort(_ points: inout [PointView],midPoint:CGPoint) { 45 | points.sort { 46 | return calculatePolarAngle(midPoint, target: $0.position) < calculatePolarAngle(midPoint, target: $1.position) 47 | } 48 | } 49 | 50 | if points.count == 3 { 51 | counterclockwiseSort(&points,midPoint: midPoint(points)!) 52 | return 53 | } 54 | 55 | var minXPoint = points[0] 56 | var maxXPoint = points[0] 57 | 58 | for point in points { 59 | minXPoint = point.position.x < minXPoint.position.x ? point : minXPoint 60 | maxXPoint = point.position.x > maxXPoint.position.x ? point : maxXPoint 61 | // println(point.position) 62 | } 63 | 64 | let divide = (minXPoint.position.x + maxXPoint.position.x)/2 65 | 66 | var left = points.filter { 67 | return $0.position.x <= divide 68 | } 69 | 70 | var right = points.filter { 71 | return $0.position.x > divide 72 | } 73 | if left.count>0 { 74 | Conquer(&left) 75 | } 76 | if right.count>0 { 77 | Conquer(&right) 78 | } 79 | 80 | var combine = left + right 81 | let middle = midPoint(left) ?? midPoint(right) 82 | //FIXME: combine 83 | counterclockwiseSort(&combine,midPoint: middle!) 84 | 85 | // for com in combine { 86 | // println(com.position) 87 | // } 88 | var stack = [PointView]() 89 | stack.append(combine[0]) 90 | stack.append(combine[1]) 91 | for point in combine[2..= 2 && checkPoint(stack.last!.position, inTriangle: (middle!,stack[stack.count-2].position,stack[0].position)) { 104 | stack.last?.isConvexHullNode = false 105 | restPoints.append(stack.last!) 106 | stack.removeLast() 107 | if stack.count < 2 { 108 | break 109 | } 110 | while stack.count >= 2 && checkPoint(stack[0].position, inTriangle: (middle!,stack.last!.position,stack[1].position)) { 111 | stack[0].isConvexHullNode = false 112 | restPoints.append(stack[0]) 113 | stack.remove(at: 0) 114 | if stack.count < 2 { 115 | break 116 | } 117 | } 118 | } 119 | 120 | while stack.count >= 2 && checkPoint(stack[0].position, inTriangle: (middle!,stack.last!.position,stack[1].position)) { 121 | stack[0].isConvexHullNode = false 122 | restPoints.append(stack[0]) 123 | stack.remove(at: 0) 124 | if stack.count < 2 { 125 | break 126 | } 127 | } 128 | 129 | points = stack 130 | } 131 | 132 | func generateConvexHull(_ points: inout [PointView]) { 133 | beginTime = Date() 134 | for point in points { 135 | point.isConvexHullNode = true 136 | } 137 | Conquer(&points) 138 | 139 | points += restPoints 140 | restPoints.removeAll(keepingCapacity: false) 141 | 142 | func adjustSort(_ points:inout [PointView],count:Int) { 143 | for _ in 0 ..< count { 144 | points.insert(points.last!, at: 0) 145 | points.removeLast() 146 | } 147 | } 148 | endTime = Date() 149 | } 150 | } 151 | -------------------------------------------------------------------------------- /ConvexHull/ConvexHull/GrahamScan.swift: -------------------------------------------------------------------------------- 1 | // 2 | // GrahamScan.swift 3 | // ConvexHull 4 | // 5 | // Created by 杨萧玉 on 14/11/25. 6 | // Copyright (c) 2014年 杨萧玉. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | import Foundation 11 | 12 | class GrahamScan: NSObject,ConvexHullGenerator { 13 | var beginTime = Date(timeIntervalSince1970: 0) 14 | var endTime = Date(timeIntervalSince1970: 0) 15 | var costTime:TimeInterval { 16 | get{ 17 | return endTime.timeIntervalSince(beginTime) 18 | } 19 | } 20 | func generateConvexHull(_ points: inout [PointView]) { 21 | beginTime = Date() 22 | for point in points { 23 | point.isConvexHullNode = true 24 | } 25 | 26 | if points.count <= 3 { 27 | return 28 | } 29 | 30 | var minYPoint = points[0] 31 | var minIndex = 0 32 | for (index,point) in points.enumerated() { 33 | (minIndex,minYPoint) = point.position.y < minYPoint.position.y ? (index,point) : (minIndex,minYPoint) 34 | } 35 | points.remove(at: minIndex) 36 | points.sort { 37 | return calculatePolarAngle(minYPoint.position, target: $0.position) < calculatePolarAngle(minYPoint.position, target: $1.position) 38 | } 39 | var stack = [minYPoint] 40 | var restPoints = [PointView]() 41 | stack.append(points[0]) 42 | 43 | for point in points[1.. Bool { 46 | let p1 = stack[stack.count-2].position 47 | let p2 = stack.last!.position 48 | let p3 = point.position 49 | let turnsRight = (p2.x - p1.x) * (p3.y - p1.y) - (p2.y - p1.y) * (p3.x - p1.x) 50 | return (turnsRight <= 0) 51 | } 52 | 53 | while checkTurnsRight() { 54 | stack.last?.isConvexHullNode = false 55 | restPoints.append(stack.last!) 56 | stack.removeLast() 57 | if stack.count < 3 { 58 | break 59 | } 60 | } 61 | stack.append(point) 62 | } 63 | points = stack + restPoints 64 | endTime = Date() 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /ConvexHull/ConvexHull/HelpMethod.swift: -------------------------------------------------------------------------------- 1 | // 2 | // HelpMethod.swift 3 | // ConvexHull 4 | // 5 | // Created by 杨萧玉 on 14/11/25. 6 | // Copyright (c) 2014年 杨萧玉. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | import AppKit 11 | 12 | protocol ChooseAlgorithm { 13 | var algorithmSelected:Algorithm {get set} 14 | var pointNumSelected:UInt32 {get set} 15 | } 16 | 17 | enum Algorithm { 18 | case bruteForceCH 19 | case grahamScan 20 | case divideAndConquer 21 | } 22 | 23 | func == (left: PointView, right: PointView) -> Bool { 24 | return left.position == right.position 25 | } 26 | 27 | func getAppDelegate() -> AppDelegate{ 28 | return NSApplication.shared().delegate as! AppDelegate 29 | } 30 | 31 | func calculatePoint(_ pointP:CGPoint,onLine line:(pointA:CGPoint,pointB:CGPoint)) -> CGFloat { 32 | return (pointP.y - line.pointA.y) * (line.pointB.x - line.pointA.x) - (line.pointB.y - line.pointA.y) * (pointP.x - line.pointA.x) 33 | } 34 | 35 | func checkPoint(_ P:CGPoint,inTriangle triangle:(A:CGPoint,B:CGPoint,C:CGPoint)) -> Bool { 36 | var Pp = calculatePoint(P, onLine: (triangle.A,triangle.B)) 37 | let AB = Pp == 0||Pp * calculatePoint(triangle.C, onLine: (triangle.A,triangle.B)) > 0 38 | if !AB{ 39 | return AB 40 | } 41 | Pp = calculatePoint(P, onLine: (triangle.A,triangle.C)) 42 | let AC = Pp == 0||Pp * calculatePoint(triangle.B, onLine: (triangle.A,triangle.C)) > 0 43 | if !AC{ 44 | return AC 45 | } 46 | Pp = calculatePoint(P, onLine: (triangle.C,triangle.B)) 47 | let BC = Pp == 0||Pp * calculatePoint(triangle.A, onLine: (triangle.C,triangle.B)) > 0 48 | 49 | return AB && AC && BC 50 | } 51 | 52 | func calculatePolarAngle(_ origin:CGPoint, target:CGPoint) -> Double { 53 | let trans = (x: target.x - origin.x, y: target.y - origin.y) 54 | let angle = atan(Double(trans.y) / Double(trans.x)) 55 | switch trans { 56 | case let (x,y) where x >= 0 && y >= 0: 57 | return angle 58 | case let (x,y) where x < 0 && y >= 0: 59 | return angle + M_PI 60 | case let (x,y) where x <= 0 && y < 0: 61 | return angle + M_PI 62 | case let (x,y) where x > 0 && y < 0: 63 | return angle + 2 * M_PI 64 | default: 65 | return 0 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /ConvexHull/ConvexHull/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "mac", 5 | "size" : "16x16", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "mac", 10 | "size" : "16x16", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "mac", 15 | "size" : "32x32", 16 | "scale" : "1x" 17 | }, 18 | { 19 | "idiom" : "mac", 20 | "size" : "32x32", 21 | "scale" : "2x" 22 | }, 23 | { 24 | "idiom" : "mac", 25 | "size" : "128x128", 26 | "scale" : "1x" 27 | }, 28 | { 29 | "idiom" : "mac", 30 | "size" : "128x128", 31 | "scale" : "2x" 32 | }, 33 | { 34 | "idiom" : "mac", 35 | "size" : "256x256", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "mac", 40 | "size" : "256x256", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "mac", 45 | "size" : "512x512", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "mac", 50 | "size" : "512x512", 51 | "scale" : "2x" 52 | } 53 | ], 54 | "info" : { 55 | "version" : 1, 56 | "author" : "xcode" 57 | } 58 | } -------------------------------------------------------------------------------- /ConvexHull/ConvexHull/Images.xcassets/RedPoint.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "scale" : "2x", 10 | "filename" : "RedPoint.png" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /ConvexHull/ConvexHull/Images.xcassets/RedPoint.imageset/RedPoint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yulingtianxia/Algorithm-Experiment/d747bdf492ca40372beaa0169b36d3098365cd09/ConvexHull/ConvexHull/Images.xcassets/RedPoint.imageset/RedPoint.png -------------------------------------------------------------------------------- /ConvexHull/ConvexHull/Images.xcassets/point.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "scale" : "2x", 10 | "filename" : "point.png" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /ConvexHull/ConvexHull/Images.xcassets/point.imageset/point.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yulingtianxia/Algorithm-Experiment/d747bdf492ca40372beaa0169b36d3098365cd09/ConvexHull/ConvexHull/Images.xcassets/point.imageset/point.png -------------------------------------------------------------------------------- /ConvexHull/ConvexHull/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSMinimumSystemVersion 26 | $(MACOSX_DEPLOYMENT_TARGET) 27 | NSHumanReadableCopyright 28 | Copyright © 2014年 杨萧玉. All rights reserved. 29 | NSMainStoryboardFile 30 | Main 31 | NSPrincipalClass 32 | NSApplication 33 | 34 | 35 | -------------------------------------------------------------------------------- /ConvexHull/ConvexHull/PointView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PointView.swift 3 | // ConvexHull 4 | // 5 | // Created by 杨萧玉 on 14/11/25. 6 | // Copyright (c) 2014年 杨萧玉. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | 11 | private let length:CGFloat = 25 12 | 13 | class PointView: NSImageView { 14 | 15 | var isConvexHullNode:Bool = false { 16 | willSet{ 17 | if newValue { 18 | image = NSImage(named: "RedPoint") 19 | } 20 | else { 21 | image = NSImage(named: "point") 22 | } 23 | } 24 | } 25 | var position:CGPoint { 26 | set{ 27 | frame.origin = CGPoint(x: newValue.x - length/2, y: newValue.y - length/2) 28 | } 29 | get{ 30 | return CGPoint(x: frame.origin.x + length/2, y: frame.origin.y + length/2) 31 | } 32 | } 33 | 34 | override func draw(_ dirtyRect: NSRect) { 35 | super.draw(dirtyRect) 36 | 37 | // Drawing code here. 38 | } 39 | 40 | init(location:CGPoint) { 41 | super.init(frame: NSRect(x: location.x - length/2, y: location.y - length/2, width: length, height: length)) 42 | image = NSImage(named: "point") 43 | } 44 | 45 | required init?(coder: NSCoder) { 46 | fatalError("init(coder:) has not been implemented") 47 | } 48 | 49 | 50 | override func mouseDragged(with theEvent: NSEvent) { 51 | 52 | // let delta = convertPoint(theEvent.locationInWindow, fromView: nil) 53 | if let location = superview?.convert(theEvent.locationInWindow, from: nil) { 54 | position = location 55 | (superview as? Background)?.makeConvexHull() 56 | } 57 | } 58 | 59 | 60 | 61 | 62 | } 63 | -------------------------------------------------------------------------------- /ConvexHull/ConvexHull/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // ConvexHull 4 | // 5 | // Created by 杨萧玉 on 14/11/24. 6 | // Copyright (c) 2014年 杨萧玉. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | 11 | protocol ConvexHullGenerator{ 12 | var beginTime:Date{get set} 13 | var endTime:Date{get set} 14 | var costTime:TimeInterval{get} 15 | func generateConvexHull(_ points:inout [PointView]) 16 | } 17 | 18 | class ViewController: NSViewController { 19 | 20 | override func viewDidLoad() { 21 | super.viewDidLoad() 22 | 23 | // Do any additional setup after loading the view. 24 | } 25 | 26 | override var representedObject: Any? { 27 | didSet { 28 | // Update the view, if already loaded. 29 | } 30 | } 31 | 32 | } 33 | 34 | -------------------------------------------------------------------------------- /ConvexHull/ConvexHullTests/ConvexHullTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ConvexHullTests.swift 3 | // ConvexHullTests 4 | // 5 | // Created by 杨萧玉 on 14/11/24. 6 | // Copyright (c) 2014年 杨萧玉. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | import XCTest 11 | 12 | class ConvexHullTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testExample() { 25 | // This is an example of a functional test case. 26 | XCTAssert(true, "Pass") 27 | } 28 | 29 | func testPerformanceExample() { 30 | // This is an example of a performance test case. 31 | self.measure() { 32 | // Put the code you want to measure the time of here. 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /ConvexHull/ConvexHullTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /DBASortLink/DBASortLink.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | A4F088E81AC7CB5F00CAF8B4 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = A4F088E71AC7CB5F00CAF8B4 /* AppDelegate.m */; }; 11 | A4F088EA1AC7CB5F00CAF8B4 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = A4F088E91AC7CB5F00CAF8B4 /* main.m */; }; 12 | A4F088ED1AC7CB5F00CAF8B4 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A4F088EC1AC7CB5F00CAF8B4 /* ViewController.m */; }; 13 | A4F088EF1AC7CB5F00CAF8B4 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A4F088EE1AC7CB5F00CAF8B4 /* Images.xcassets */; }; 14 | A4F088F21AC7CB5F00CAF8B4 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A4F088F01AC7CB5F00CAF8B4 /* Main.storyboard */; }; 15 | A4F088FE1AC7CB5F00CAF8B4 /* DBASortLinkTests.m in Sources */ = {isa = PBXBuildFile; fileRef = A4F088FD1AC7CB5F00CAF8B4 /* DBASortLinkTests.m */; }; 16 | A4F0890A1AC7CC8200CAF8B4 /* DataFactory.m in Sources */ = {isa = PBXBuildFile; fileRef = A4F089091AC7CC8200CAF8B4 /* DataFactory.m */; }; 17 | A4F0890D1AC7D5B500CAF8B4 /* DataSorter.m in Sources */ = {isa = PBXBuildFile; fileRef = A4F0890C1AC7D5B500CAF8B4 /* DataSorter.m */; }; 18 | A4F089101AC7F5DD00CAF8B4 /* DataLinker.m in Sources */ = {isa = PBXBuildFile; fileRef = A4F0890F1AC7F5DD00CAF8B4 /* DataLinker.m */; }; 19 | /* End PBXBuildFile section */ 20 | 21 | /* Begin PBXContainerItemProxy section */ 22 | A4F088F81AC7CB5F00CAF8B4 /* PBXContainerItemProxy */ = { 23 | isa = PBXContainerItemProxy; 24 | containerPortal = A4F088D91AC7CB5E00CAF8B4 /* Project object */; 25 | proxyType = 1; 26 | remoteGlobalIDString = A4F088E01AC7CB5E00CAF8B4; 27 | remoteInfo = DBASortLink; 28 | }; 29 | /* End PBXContainerItemProxy section */ 30 | 31 | /* Begin PBXFileReference section */ 32 | A4F088E11AC7CB5E00CAF8B4 /* DBASortLink.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DBASortLink.app; sourceTree = BUILT_PRODUCTS_DIR; }; 33 | A4F088E51AC7CB5F00CAF8B4 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 34 | A4F088E61AC7CB5F00CAF8B4 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 35 | A4F088E71AC7CB5F00CAF8B4 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 36 | A4F088E91AC7CB5F00CAF8B4 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 37 | A4F088EB1AC7CB5F00CAF8B4 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 38 | A4F088EC1AC7CB5F00CAF8B4 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 39 | A4F088EE1AC7CB5F00CAF8B4 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 40 | A4F088F11AC7CB5F00CAF8B4 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 41 | A4F088F71AC7CB5F00CAF8B4 /* DBASortLinkTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = DBASortLinkTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 42 | A4F088FC1AC7CB5F00CAF8B4 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 43 | A4F088FD1AC7CB5F00CAF8B4 /* DBASortLinkTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DBASortLinkTests.m; sourceTree = ""; }; 44 | A4F089081AC7CC8200CAF8B4 /* DataFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DataFactory.h; sourceTree = ""; }; 45 | A4F089091AC7CC8200CAF8B4 /* DataFactory.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DataFactory.m; sourceTree = ""; }; 46 | A4F0890B1AC7D5B500CAF8B4 /* DataSorter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DataSorter.h; sourceTree = ""; }; 47 | A4F0890C1AC7D5B500CAF8B4 /* DataSorter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DataSorter.m; sourceTree = ""; }; 48 | A4F0890E1AC7F5DD00CAF8B4 /* DataLinker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DataLinker.h; sourceTree = ""; }; 49 | A4F0890F1AC7F5DD00CAF8B4 /* DataLinker.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DataLinker.m; sourceTree = ""; }; 50 | /* End PBXFileReference section */ 51 | 52 | /* Begin PBXFrameworksBuildPhase section */ 53 | A4F088DE1AC7CB5E00CAF8B4 /* Frameworks */ = { 54 | isa = PBXFrameworksBuildPhase; 55 | buildActionMask = 2147483647; 56 | files = ( 57 | ); 58 | runOnlyForDeploymentPostprocessing = 0; 59 | }; 60 | A4F088F41AC7CB5F00CAF8B4 /* Frameworks */ = { 61 | isa = PBXFrameworksBuildPhase; 62 | buildActionMask = 2147483647; 63 | files = ( 64 | ); 65 | runOnlyForDeploymentPostprocessing = 0; 66 | }; 67 | /* End PBXFrameworksBuildPhase section */ 68 | 69 | /* Begin PBXGroup section */ 70 | A4F088D81AC7CB5E00CAF8B4 = { 71 | isa = PBXGroup; 72 | children = ( 73 | A4F088E31AC7CB5F00CAF8B4 /* DBASortLink */, 74 | A4F088FA1AC7CB5F00CAF8B4 /* DBASortLinkTests */, 75 | A4F088E21AC7CB5E00CAF8B4 /* Products */, 76 | ); 77 | sourceTree = ""; 78 | }; 79 | A4F088E21AC7CB5E00CAF8B4 /* Products */ = { 80 | isa = PBXGroup; 81 | children = ( 82 | A4F088E11AC7CB5E00CAF8B4 /* DBASortLink.app */, 83 | A4F088F71AC7CB5F00CAF8B4 /* DBASortLinkTests.xctest */, 84 | ); 85 | name = Products; 86 | sourceTree = ""; 87 | }; 88 | A4F088E31AC7CB5F00CAF8B4 /* DBASortLink */ = { 89 | isa = PBXGroup; 90 | children = ( 91 | A4F089071AC7CC4F00CAF8B4 /* Tools */, 92 | A4F088E61AC7CB5F00CAF8B4 /* AppDelegate.h */, 93 | A4F088E71AC7CB5F00CAF8B4 /* AppDelegate.m */, 94 | A4F088EB1AC7CB5F00CAF8B4 /* ViewController.h */, 95 | A4F088EC1AC7CB5F00CAF8B4 /* ViewController.m */, 96 | A4F088EE1AC7CB5F00CAF8B4 /* Images.xcassets */, 97 | A4F088F01AC7CB5F00CAF8B4 /* Main.storyboard */, 98 | A4F088E41AC7CB5F00CAF8B4 /* Supporting Files */, 99 | ); 100 | path = DBASortLink; 101 | sourceTree = ""; 102 | }; 103 | A4F088E41AC7CB5F00CAF8B4 /* Supporting Files */ = { 104 | isa = PBXGroup; 105 | children = ( 106 | A4F088E51AC7CB5F00CAF8B4 /* Info.plist */, 107 | A4F088E91AC7CB5F00CAF8B4 /* main.m */, 108 | ); 109 | name = "Supporting Files"; 110 | sourceTree = ""; 111 | }; 112 | A4F088FA1AC7CB5F00CAF8B4 /* DBASortLinkTests */ = { 113 | isa = PBXGroup; 114 | children = ( 115 | A4F088FD1AC7CB5F00CAF8B4 /* DBASortLinkTests.m */, 116 | A4F088FB1AC7CB5F00CAF8B4 /* Supporting Files */, 117 | ); 118 | path = DBASortLinkTests; 119 | sourceTree = ""; 120 | }; 121 | A4F088FB1AC7CB5F00CAF8B4 /* Supporting Files */ = { 122 | isa = PBXGroup; 123 | children = ( 124 | A4F088FC1AC7CB5F00CAF8B4 /* Info.plist */, 125 | ); 126 | name = "Supporting Files"; 127 | sourceTree = ""; 128 | }; 129 | A4F089071AC7CC4F00CAF8B4 /* Tools */ = { 130 | isa = PBXGroup; 131 | children = ( 132 | A4F089081AC7CC8200CAF8B4 /* DataFactory.h */, 133 | A4F089091AC7CC8200CAF8B4 /* DataFactory.m */, 134 | A4F0890B1AC7D5B500CAF8B4 /* DataSorter.h */, 135 | A4F0890C1AC7D5B500CAF8B4 /* DataSorter.m */, 136 | A4F0890E1AC7F5DD00CAF8B4 /* DataLinker.h */, 137 | A4F0890F1AC7F5DD00CAF8B4 /* DataLinker.m */, 138 | ); 139 | name = Tools; 140 | sourceTree = ""; 141 | }; 142 | /* End PBXGroup section */ 143 | 144 | /* Begin PBXNativeTarget section */ 145 | A4F088E01AC7CB5E00CAF8B4 /* DBASortLink */ = { 146 | isa = PBXNativeTarget; 147 | buildConfigurationList = A4F089011AC7CB5F00CAF8B4 /* Build configuration list for PBXNativeTarget "DBASortLink" */; 148 | buildPhases = ( 149 | A4F088DD1AC7CB5E00CAF8B4 /* Sources */, 150 | A4F088DE1AC7CB5E00CAF8B4 /* Frameworks */, 151 | A4F088DF1AC7CB5E00CAF8B4 /* Resources */, 152 | ); 153 | buildRules = ( 154 | ); 155 | dependencies = ( 156 | ); 157 | name = DBASortLink; 158 | productName = DBASortLink; 159 | productReference = A4F088E11AC7CB5E00CAF8B4 /* DBASortLink.app */; 160 | productType = "com.apple.product-type.application"; 161 | }; 162 | A4F088F61AC7CB5F00CAF8B4 /* DBASortLinkTests */ = { 163 | isa = PBXNativeTarget; 164 | buildConfigurationList = A4F089041AC7CB5F00CAF8B4 /* Build configuration list for PBXNativeTarget "DBASortLinkTests" */; 165 | buildPhases = ( 166 | A4F088F31AC7CB5F00CAF8B4 /* Sources */, 167 | A4F088F41AC7CB5F00CAF8B4 /* Frameworks */, 168 | A4F088F51AC7CB5F00CAF8B4 /* Resources */, 169 | ); 170 | buildRules = ( 171 | ); 172 | dependencies = ( 173 | A4F088F91AC7CB5F00CAF8B4 /* PBXTargetDependency */, 174 | ); 175 | name = DBASortLinkTests; 176 | productName = DBASortLinkTests; 177 | productReference = A4F088F71AC7CB5F00CAF8B4 /* DBASortLinkTests.xctest */; 178 | productType = "com.apple.product-type.bundle.unit-test"; 179 | }; 180 | /* End PBXNativeTarget section */ 181 | 182 | /* Begin PBXProject section */ 183 | A4F088D91AC7CB5E00CAF8B4 /* Project object */ = { 184 | isa = PBXProject; 185 | attributes = { 186 | LastUpgradeCheck = 0700; 187 | ORGANIZATIONNAME = "杨萧玉"; 188 | TargetAttributes = { 189 | A4F088E01AC7CB5E00CAF8B4 = { 190 | CreatedOnToolsVersion = 6.3; 191 | }; 192 | A4F088F61AC7CB5F00CAF8B4 = { 193 | CreatedOnToolsVersion = 6.3; 194 | TestTargetID = A4F088E01AC7CB5E00CAF8B4; 195 | }; 196 | }; 197 | }; 198 | buildConfigurationList = A4F088DC1AC7CB5E00CAF8B4 /* Build configuration list for PBXProject "DBASortLink" */; 199 | compatibilityVersion = "Xcode 3.2"; 200 | developmentRegion = English; 201 | hasScannedForEncodings = 0; 202 | knownRegions = ( 203 | en, 204 | Base, 205 | ); 206 | mainGroup = A4F088D81AC7CB5E00CAF8B4; 207 | productRefGroup = A4F088E21AC7CB5E00CAF8B4 /* Products */; 208 | projectDirPath = ""; 209 | projectRoot = ""; 210 | targets = ( 211 | A4F088E01AC7CB5E00CAF8B4 /* DBASortLink */, 212 | A4F088F61AC7CB5F00CAF8B4 /* DBASortLinkTests */, 213 | ); 214 | }; 215 | /* End PBXProject section */ 216 | 217 | /* Begin PBXResourcesBuildPhase section */ 218 | A4F088DF1AC7CB5E00CAF8B4 /* Resources */ = { 219 | isa = PBXResourcesBuildPhase; 220 | buildActionMask = 2147483647; 221 | files = ( 222 | A4F088EF1AC7CB5F00CAF8B4 /* Images.xcassets in Resources */, 223 | A4F088F21AC7CB5F00CAF8B4 /* Main.storyboard in Resources */, 224 | ); 225 | runOnlyForDeploymentPostprocessing = 0; 226 | }; 227 | A4F088F51AC7CB5F00CAF8B4 /* Resources */ = { 228 | isa = PBXResourcesBuildPhase; 229 | buildActionMask = 2147483647; 230 | files = ( 231 | ); 232 | runOnlyForDeploymentPostprocessing = 0; 233 | }; 234 | /* End PBXResourcesBuildPhase section */ 235 | 236 | /* Begin PBXSourcesBuildPhase section */ 237 | A4F088DD1AC7CB5E00CAF8B4 /* Sources */ = { 238 | isa = PBXSourcesBuildPhase; 239 | buildActionMask = 2147483647; 240 | files = ( 241 | A4F088ED1AC7CB5F00CAF8B4 /* ViewController.m in Sources */, 242 | A4F088EA1AC7CB5F00CAF8B4 /* main.m in Sources */, 243 | A4F089101AC7F5DD00CAF8B4 /* DataLinker.m in Sources */, 244 | A4F0890D1AC7D5B500CAF8B4 /* DataSorter.m in Sources */, 245 | A4F0890A1AC7CC8200CAF8B4 /* DataFactory.m in Sources */, 246 | A4F088E81AC7CB5F00CAF8B4 /* AppDelegate.m in Sources */, 247 | ); 248 | runOnlyForDeploymentPostprocessing = 0; 249 | }; 250 | A4F088F31AC7CB5F00CAF8B4 /* Sources */ = { 251 | isa = PBXSourcesBuildPhase; 252 | buildActionMask = 2147483647; 253 | files = ( 254 | A4F088FE1AC7CB5F00CAF8B4 /* DBASortLinkTests.m in Sources */, 255 | ); 256 | runOnlyForDeploymentPostprocessing = 0; 257 | }; 258 | /* End PBXSourcesBuildPhase section */ 259 | 260 | /* Begin PBXTargetDependency section */ 261 | A4F088F91AC7CB5F00CAF8B4 /* PBXTargetDependency */ = { 262 | isa = PBXTargetDependency; 263 | target = A4F088E01AC7CB5E00CAF8B4 /* DBASortLink */; 264 | targetProxy = A4F088F81AC7CB5F00CAF8B4 /* PBXContainerItemProxy */; 265 | }; 266 | /* End PBXTargetDependency section */ 267 | 268 | /* Begin PBXVariantGroup section */ 269 | A4F088F01AC7CB5F00CAF8B4 /* Main.storyboard */ = { 270 | isa = PBXVariantGroup; 271 | children = ( 272 | A4F088F11AC7CB5F00CAF8B4 /* Base */, 273 | ); 274 | name = Main.storyboard; 275 | sourceTree = ""; 276 | }; 277 | /* End PBXVariantGroup section */ 278 | 279 | /* Begin XCBuildConfiguration section */ 280 | A4F088FF1AC7CB5F00CAF8B4 /* Debug */ = { 281 | isa = XCBuildConfiguration; 282 | buildSettings = { 283 | ALWAYS_SEARCH_USER_PATHS = NO; 284 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 285 | CLANG_CXX_LIBRARY = "libc++"; 286 | CLANG_ENABLE_MODULES = YES; 287 | CLANG_ENABLE_OBJC_ARC = YES; 288 | CLANG_WARN_BOOL_CONVERSION = YES; 289 | CLANG_WARN_CONSTANT_CONVERSION = YES; 290 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 291 | CLANG_WARN_EMPTY_BODY = YES; 292 | CLANG_WARN_ENUM_CONVERSION = YES; 293 | CLANG_WARN_INT_CONVERSION = YES; 294 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 295 | CLANG_WARN_UNREACHABLE_CODE = YES; 296 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 297 | CODE_SIGN_IDENTITY = "-"; 298 | COPY_PHASE_STRIP = NO; 299 | DEBUG_INFORMATION_FORMAT = dwarf; 300 | ENABLE_STRICT_OBJC_MSGSEND = YES; 301 | ENABLE_TESTABILITY = YES; 302 | GCC_C_LANGUAGE_STANDARD = gnu99; 303 | GCC_DYNAMIC_NO_PIC = NO; 304 | GCC_NO_COMMON_BLOCKS = YES; 305 | GCC_OPTIMIZATION_LEVEL = 0; 306 | GCC_PREPROCESSOR_DEFINITIONS = ( 307 | "DEBUG=1", 308 | "$(inherited)", 309 | ); 310 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 311 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 312 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 313 | GCC_WARN_UNDECLARED_SELECTOR = YES; 314 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 315 | GCC_WARN_UNUSED_FUNCTION = YES; 316 | GCC_WARN_UNUSED_VARIABLE = YES; 317 | MACOSX_DEPLOYMENT_TARGET = 10.10; 318 | MTL_ENABLE_DEBUG_INFO = YES; 319 | ONLY_ACTIVE_ARCH = YES; 320 | SDKROOT = macosx; 321 | }; 322 | name = Debug; 323 | }; 324 | A4F089001AC7CB5F00CAF8B4 /* Release */ = { 325 | isa = XCBuildConfiguration; 326 | buildSettings = { 327 | ALWAYS_SEARCH_USER_PATHS = NO; 328 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 329 | CLANG_CXX_LIBRARY = "libc++"; 330 | CLANG_ENABLE_MODULES = YES; 331 | CLANG_ENABLE_OBJC_ARC = YES; 332 | CLANG_WARN_BOOL_CONVERSION = YES; 333 | CLANG_WARN_CONSTANT_CONVERSION = YES; 334 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 335 | CLANG_WARN_EMPTY_BODY = YES; 336 | CLANG_WARN_ENUM_CONVERSION = YES; 337 | CLANG_WARN_INT_CONVERSION = YES; 338 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 339 | CLANG_WARN_UNREACHABLE_CODE = YES; 340 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 341 | CODE_SIGN_IDENTITY = "-"; 342 | COPY_PHASE_STRIP = NO; 343 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 344 | ENABLE_NS_ASSERTIONS = NO; 345 | ENABLE_STRICT_OBJC_MSGSEND = YES; 346 | GCC_C_LANGUAGE_STANDARD = gnu99; 347 | GCC_NO_COMMON_BLOCKS = YES; 348 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 349 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 350 | GCC_WARN_UNDECLARED_SELECTOR = YES; 351 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 352 | GCC_WARN_UNUSED_FUNCTION = YES; 353 | GCC_WARN_UNUSED_VARIABLE = YES; 354 | MACOSX_DEPLOYMENT_TARGET = 10.10; 355 | MTL_ENABLE_DEBUG_INFO = NO; 356 | SDKROOT = macosx; 357 | }; 358 | name = Release; 359 | }; 360 | A4F089021AC7CB5F00CAF8B4 /* Debug */ = { 361 | isa = XCBuildConfiguration; 362 | buildSettings = { 363 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 364 | COMBINE_HIDPI_IMAGES = YES; 365 | INFOPLIST_FILE = DBASortLink/Info.plist; 366 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; 367 | PRODUCT_BUNDLE_IDENTIFIER = "com.yxy.$(PRODUCT_NAME:rfc1034identifier)"; 368 | PRODUCT_NAME = "$(TARGET_NAME)"; 369 | }; 370 | name = Debug; 371 | }; 372 | A4F089031AC7CB5F00CAF8B4 /* Release */ = { 373 | isa = XCBuildConfiguration; 374 | buildSettings = { 375 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 376 | COMBINE_HIDPI_IMAGES = YES; 377 | INFOPLIST_FILE = DBASortLink/Info.plist; 378 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; 379 | PRODUCT_BUNDLE_IDENTIFIER = "com.yxy.$(PRODUCT_NAME:rfc1034identifier)"; 380 | PRODUCT_NAME = "$(TARGET_NAME)"; 381 | }; 382 | name = Release; 383 | }; 384 | A4F089051AC7CB5F00CAF8B4 /* Debug */ = { 385 | isa = XCBuildConfiguration; 386 | buildSettings = { 387 | BUNDLE_LOADER = "$(TEST_HOST)"; 388 | COMBINE_HIDPI_IMAGES = YES; 389 | FRAMEWORK_SEARCH_PATHS = ( 390 | "$(DEVELOPER_FRAMEWORKS_DIR)", 391 | "$(inherited)", 392 | ); 393 | GCC_PREPROCESSOR_DEFINITIONS = ( 394 | "DEBUG=1", 395 | "$(inherited)", 396 | ); 397 | INFOPLIST_FILE = DBASortLinkTests/Info.plist; 398 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; 399 | PRODUCT_BUNDLE_IDENTIFIER = "com.yxy.$(PRODUCT_NAME:rfc1034identifier)"; 400 | PRODUCT_NAME = "$(TARGET_NAME)"; 401 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/DBASortLink.app/Contents/MacOS/DBASortLink"; 402 | }; 403 | name = Debug; 404 | }; 405 | A4F089061AC7CB5F00CAF8B4 /* Release */ = { 406 | isa = XCBuildConfiguration; 407 | buildSettings = { 408 | BUNDLE_LOADER = "$(TEST_HOST)"; 409 | COMBINE_HIDPI_IMAGES = YES; 410 | FRAMEWORK_SEARCH_PATHS = ( 411 | "$(DEVELOPER_FRAMEWORKS_DIR)", 412 | "$(inherited)", 413 | ); 414 | INFOPLIST_FILE = DBASortLinkTests/Info.plist; 415 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; 416 | PRODUCT_BUNDLE_IDENTIFIER = "com.yxy.$(PRODUCT_NAME:rfc1034identifier)"; 417 | PRODUCT_NAME = "$(TARGET_NAME)"; 418 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/DBASortLink.app/Contents/MacOS/DBASortLink"; 419 | }; 420 | name = Release; 421 | }; 422 | /* End XCBuildConfiguration section */ 423 | 424 | /* Begin XCConfigurationList section */ 425 | A4F088DC1AC7CB5E00CAF8B4 /* Build configuration list for PBXProject "DBASortLink" */ = { 426 | isa = XCConfigurationList; 427 | buildConfigurations = ( 428 | A4F088FF1AC7CB5F00CAF8B4 /* Debug */, 429 | A4F089001AC7CB5F00CAF8B4 /* Release */, 430 | ); 431 | defaultConfigurationIsVisible = 0; 432 | defaultConfigurationName = Release; 433 | }; 434 | A4F089011AC7CB5F00CAF8B4 /* Build configuration list for PBXNativeTarget "DBASortLink" */ = { 435 | isa = XCConfigurationList; 436 | buildConfigurations = ( 437 | A4F089021AC7CB5F00CAF8B4 /* Debug */, 438 | A4F089031AC7CB5F00CAF8B4 /* Release */, 439 | ); 440 | defaultConfigurationIsVisible = 0; 441 | defaultConfigurationName = Release; 442 | }; 443 | A4F089041AC7CB5F00CAF8B4 /* Build configuration list for PBXNativeTarget "DBASortLinkTests" */ = { 444 | isa = XCConfigurationList; 445 | buildConfigurations = ( 446 | A4F089051AC7CB5F00CAF8B4 /* Debug */, 447 | A4F089061AC7CB5F00CAF8B4 /* Release */, 448 | ); 449 | defaultConfigurationIsVisible = 0; 450 | defaultConfigurationName = Release; 451 | }; 452 | /* End XCConfigurationList section */ 453 | }; 454 | rootObject = A4F088D91AC7CB5E00CAF8B4 /* Project object */; 455 | } 456 | -------------------------------------------------------------------------------- /DBASortLink/DBASortLink.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /DBASortLink/DBASortLink/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // DBASortLink 4 | // 5 | // Created by 杨萧玉 on 15/3/29. 6 | // Copyright (c) 2015年 杨萧玉. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : NSObject 12 | 13 | @property (readonly) NSArray *dataArray; 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /DBASortLink/DBASortLink/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // DBASortLink 4 | // 5 | // Created by 杨萧玉 on 15/3/29. 6 | // Copyright (c) 2015年 杨萧玉. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { 18 | // Insert code here to initialize your application 19 | 20 | } 21 | 22 | - (void)applicationWillTerminate:(NSNotification *)aNotification { 23 | // Insert code here to tear down your application 24 | } 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /DBASortLink/DBASortLink/DataFactory.h: -------------------------------------------------------------------------------- 1 | // 2 | // DataFactory.h 3 | // DBASortLink 4 | // 5 | // Created by 杨萧玉 on 15/3/29. 6 | // Copyright (c) 2015年 杨萧玉. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface DataFactory : NSObject 12 | + (NSArray *)generateDataFiles; 13 | @end 14 | -------------------------------------------------------------------------------- /DBASortLink/DBASortLink/DataFactory.m: -------------------------------------------------------------------------------- 1 | // 2 | // DataFactory.m 3 | // DBASortLink 4 | // 5 | // Created by 杨萧玉 on 15/3/29. 6 | // Copyright (c) 2015年 杨萧玉. All rights reserved. 7 | // 8 | 9 | #import "DataFactory.h" 10 | #define lengthOfTable 10000 11 | @implementation DataFactory 12 | //R(ID,phone) S(ID,age) 13 | 14 | + (NSArray *)generateDataFiles { 15 | NSString *pathOfR = @"/Users/yangxiaoyu/Desktop/R.dat"; 16 | NSString *pathOfS = @"/Users/yangxiaoyu/Desktop/S.dat"; 17 | NSMutableData* writerR = [[NSMutableData alloc] init]; 18 | NSMutableData* writerS = [[NSMutableData alloc] init]; 19 | for(int i=0;i 10 | 11 | @interface DataLinker : NSObject 12 | + (NSArray *)linkTableR:(NSString *) pathR withTableS:(NSString *) pathS; 13 | @end 14 | -------------------------------------------------------------------------------- /DBASortLink/DBASortLink/DataLinker.m: -------------------------------------------------------------------------------- 1 | // 2 | // DataLinker.m 3 | // DBASortLink 4 | // 5 | // Created by 杨萧玉 on 15/3/29. 6 | // Copyright (c) 2015年 杨萧玉. All rights reserved. 7 | // 8 | 9 | #import "DataLinker.h" 10 | #define M 100 11 | @implementation DataLinker 12 | + (NSArray *)linkTableR:(NSString *) pathR withTableS:(NSString *) pathS { 13 | NSData* readerR = [NSData dataWithContentsOfFile:pathR]; 14 | NSData* readerS = [NSData dataWithContentsOfFile:pathS]; 15 | // NSMutableData* writer = [[NSMutableData alloc] init]; 16 | NSMutableArray *result = [NSMutableArray array]; 17 | int needleR=0; 18 | int needleS=0; 19 | NSMutableSet *arrayR = [NSMutableSet set]; 20 | NSMutableSet *arrayS = [NSMutableSet set]; 21 | // NSMutableArray *arrayR = [NSMutableArray array]; 22 | // NSMutableArray *arrayS = [NSMutableArray array]; 23 | int lastRa = 0; 24 | int lastSa = 0; 25 | while (needleR 10 | 11 | @interface DataSorter : NSObject 12 | + (void)sortDataWithPath:(NSString *)filePath; 13 | @end 14 | -------------------------------------------------------------------------------- /DBASortLink/DBASortLink/DataSorter.m: -------------------------------------------------------------------------------- 1 | // 2 | // DataSorter.m 3 | // DBASortLink 4 | // 5 | // Created by 杨萧玉 on 15/3/29. 6 | // Copyright (c) 2015年 杨萧玉. All rights reserved. 7 | // 8 | 9 | #import "DataSorter.h" 10 | #define M 100 11 | #define tupleSize 8 12 | 13 | @implementation DataSorter 14 | + (void)sortDataWithPath:(NSString *)filePath{ 15 | NSData* reader = [NSData dataWithContentsOfFile:filePath]; 16 | NSMutableData* writer = [[NSMutableData alloc] init]; 17 | for (int i=0; i 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSMinimumSystemVersion 26 | $(MACOSX_DEPLOYMENT_TARGET) 27 | NSHumanReadableCopyright 28 | Copyright © 2015年 杨萧玉. All rights reserved. 29 | NSMainStoryboardFile 30 | Main 31 | NSPrincipalClass 32 | NSApplication 33 | 34 | 35 | -------------------------------------------------------------------------------- /DBASortLink/DBASortLink/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // DBASortLink 4 | // 5 | // Created by 杨萧玉 on 15/3/29. 6 | // Copyright (c) 2015年 杨萧玉. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : NSViewController 12 | @property (weak) IBOutlet NSTableView *dataTable; 13 | 14 | 15 | @end 16 | 17 | -------------------------------------------------------------------------------- /DBASortLink/DBASortLink/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // DBASortLink 4 | // 5 | // Created by 杨萧玉 on 15/3/29. 6 | // Copyright (c) 2015年 杨萧玉. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "DataFactory.h" 11 | #import "DataSorter.h" 12 | #import "DataLinker.h" 13 | 14 | @implementation ViewController 15 | NSArray *dataArray; 16 | - (void)viewDidLoad { 17 | [super viewDidLoad]; 18 | 19 | // Do any additional setup after loading the view. 20 | NSArray *paths = [DataFactory generateDataFiles]; 21 | [DataSorter sortDataWithPath:paths[0]]; 22 | [DataSorter sortDataWithPath:paths[1]]; 23 | dataArray = [DataLinker linkTableR:paths[0] withTableS:paths[1]]; 24 | } 25 | 26 | - (void)setRepresentedObject:(id)representedObject { 27 | super.representedObject = representedObject; 28 | 29 | // Update the view, if already loaded. 30 | } 31 | 32 | - (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView{ 33 | return dataArray.count; 34 | } 35 | 36 | - (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row{ 37 | int column=0; 38 | if ([tableColumn.identifier isEqualToString:@"ID"]) { 39 | column=0; 40 | } 41 | else if ([tableColumn.identifier isEqualToString:@"phone"]) { 42 | column=1; 43 | } 44 | else if ([tableColumn.identifier isEqualToString:@"age"]) { 45 | column=2; 46 | } 47 | NSArray *tuple = dataArray[row]; 48 | return tuple[column]; 49 | } 50 | @end 51 | -------------------------------------------------------------------------------- /DBASortLink/DBASortLink/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // DBASortLink 4 | // 5 | // Created by 杨萧玉 on 15/3/29. 6 | // Copyright (c) 2015年 杨萧玉. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, const char * argv[]) { 12 | return NSApplicationMain(argc, argv); 13 | } 14 | -------------------------------------------------------------------------------- /DBASortLink/DBASortLinkTests/DBASortLinkTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // DBASortLinkTests.m 3 | // DBASortLinkTests 4 | // 5 | // Created by 杨萧玉 on 15/3/29. 6 | // Copyright (c) 2015年 杨萧玉. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface DBASortLinkTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation DBASortLinkTests 17 | 18 | - (void)setUp { 19 | [super setUp]; 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | } 22 | 23 | - (void)tearDown { 24 | // Put teardown code here. This method is called after the invocation of each test method in the class. 25 | [super tearDown]; 26 | } 27 | 28 | - (void)testExample { 29 | // This is an example of a functional test case. 30 | XCTAssert(YES, @"Pass"); 31 | } 32 | 33 | - (void)testPerformanceExample { 34 | // This is an example of a performance test case. 35 | [self measureBlock:^{ 36 | // Put the code you want to measure the time of here. 37 | }]; 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /DBASortLink/DBASortLinkTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /Hamiltonian/Hamiltonian.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | A40E7B0F1A3B1BC30095A1A6 /* BaseTreeSearching.swift in Sources */ = {isa = PBXBuildFile; fileRef = A40E7B0E1A3B1BC30095A1A6 /* BaseTreeSearching.swift */; }; 11 | A41C0FA61A3FFB98002DCF8D /* HillClimbingSearch.swift in Sources */ = {isa = PBXBuildFile; fileRef = A41C0FA51A3FFB98002DCF8D /* HillClimbingSearch.swift */; }; 12 | A48D84C51A3D45F600BB5B55 /* MySearching.swift in Sources */ = {isa = PBXBuildFile; fileRef = A48D84C41A3D45F600BB5B55 /* MySearching.swift */; }; 13 | A4FAC67A1A3ACF0400895556 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = A4FAC6791A3ACF0400895556 /* AppDelegate.swift */; }; 14 | A4FAC67C1A3ACF0400895556 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A4FAC67B1A3ACF0400895556 /* ViewController.swift */; }; 15 | A4FAC67E1A3ACF0400895556 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A4FAC67D1A3ACF0400895556 /* Images.xcassets */; }; 16 | A4FAC6811A3ACF0400895556 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A4FAC67F1A3ACF0400895556 /* Main.storyboard */; }; 17 | A4FAC68D1A3ACF0400895556 /* HamiltonianTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A4FAC68C1A3ACF0400895556 /* HamiltonianTests.swift */; }; 18 | A4FAC6981A3AD0E600895556 /* Background.swift in Sources */ = {isa = PBXBuildFile; fileRef = A4FAC6971A3AD0E600895556 /* Background.swift */; }; 19 | A4FAC69A1A3AD10A00895556 /* PointView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A4FAC6991A3AD10A00895556 /* PointView.swift */; }; 20 | A4FAC69E1A3AD1C200895556 /* HelpMethod.swift in Sources */ = {isa = PBXBuildFile; fileRef = A4FAC69D1A3AD1C200895556 /* HelpMethod.swift */; }; 21 | /* End PBXBuildFile section */ 22 | 23 | /* Begin PBXContainerItemProxy section */ 24 | A4FAC6871A3ACF0400895556 /* PBXContainerItemProxy */ = { 25 | isa = PBXContainerItemProxy; 26 | containerPortal = A4FAC66C1A3ACF0400895556 /* Project object */; 27 | proxyType = 1; 28 | remoteGlobalIDString = A4FAC6731A3ACF0400895556; 29 | remoteInfo = Hamiltonian; 30 | }; 31 | /* End PBXContainerItemProxy section */ 32 | 33 | /* Begin PBXFileReference section */ 34 | A40E7B0E1A3B1BC30095A1A6 /* BaseTreeSearching.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BaseTreeSearching.swift; sourceTree = ""; }; 35 | A41C0FA51A3FFB98002DCF8D /* HillClimbingSearch.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HillClimbingSearch.swift; sourceTree = ""; }; 36 | A48D84C41A3D45F600BB5B55 /* MySearching.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MySearching.swift; sourceTree = ""; }; 37 | A4FAC6741A3ACF0400895556 /* Hamiltonian.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Hamiltonian.app; sourceTree = BUILT_PRODUCTS_DIR; }; 38 | A4FAC6781A3ACF0400895556 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 39 | A4FAC6791A3ACF0400895556 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 40 | A4FAC67B1A3ACF0400895556 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 41 | A4FAC67D1A3ACF0400895556 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 42 | A4FAC6801A3ACF0400895556 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 43 | A4FAC6861A3ACF0400895556 /* HamiltonianTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = HamiltonianTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 44 | A4FAC68B1A3ACF0400895556 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 45 | A4FAC68C1A3ACF0400895556 /* HamiltonianTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HamiltonianTests.swift; sourceTree = ""; }; 46 | A4FAC6971A3AD0E600895556 /* Background.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Background.swift; sourceTree = ""; }; 47 | A4FAC6991A3AD10A00895556 /* PointView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PointView.swift; sourceTree = ""; }; 48 | A4FAC69D1A3AD1C200895556 /* HelpMethod.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HelpMethod.swift; sourceTree = ""; }; 49 | /* End PBXFileReference section */ 50 | 51 | /* Begin PBXFrameworksBuildPhase section */ 52 | A4FAC6711A3ACF0400895556 /* Frameworks */ = { 53 | isa = PBXFrameworksBuildPhase; 54 | buildActionMask = 2147483647; 55 | files = ( 56 | ); 57 | runOnlyForDeploymentPostprocessing = 0; 58 | }; 59 | A4FAC6831A3ACF0400895556 /* Frameworks */ = { 60 | isa = PBXFrameworksBuildPhase; 61 | buildActionMask = 2147483647; 62 | files = ( 63 | ); 64 | runOnlyForDeploymentPostprocessing = 0; 65 | }; 66 | /* End PBXFrameworksBuildPhase section */ 67 | 68 | /* Begin PBXGroup section */ 69 | A4FAC66B1A3ACF0400895556 = { 70 | isa = PBXGroup; 71 | children = ( 72 | A4FAC6761A3ACF0400895556 /* Hamiltonian */, 73 | A4FAC6891A3ACF0400895556 /* HamiltonianTests */, 74 | A4FAC6751A3ACF0400895556 /* Products */, 75 | ); 76 | sourceTree = ""; 77 | }; 78 | A4FAC6751A3ACF0400895556 /* Products */ = { 79 | isa = PBXGroup; 80 | children = ( 81 | A4FAC6741A3ACF0400895556 /* Hamiltonian.app */, 82 | A4FAC6861A3ACF0400895556 /* HamiltonianTests.xctest */, 83 | ); 84 | name = Products; 85 | sourceTree = ""; 86 | }; 87 | A4FAC6761A3ACF0400895556 /* Hamiltonian */ = { 88 | isa = PBXGroup; 89 | children = ( 90 | A4FAC69C1A3AD15700895556 /* Utils */, 91 | A4FAC69B1A3AD14200895556 /* Algorithm */, 92 | A4FAC6961A3AD0B600895556 /* Views */, 93 | A4FAC6791A3ACF0400895556 /* AppDelegate.swift */, 94 | A4FAC67B1A3ACF0400895556 /* ViewController.swift */, 95 | A4FAC67D1A3ACF0400895556 /* Images.xcassets */, 96 | A4FAC67F1A3ACF0400895556 /* Main.storyboard */, 97 | A4FAC6771A3ACF0400895556 /* Supporting Files */, 98 | ); 99 | path = Hamiltonian; 100 | sourceTree = ""; 101 | }; 102 | A4FAC6771A3ACF0400895556 /* Supporting Files */ = { 103 | isa = PBXGroup; 104 | children = ( 105 | A4FAC6781A3ACF0400895556 /* Info.plist */, 106 | ); 107 | name = "Supporting Files"; 108 | sourceTree = ""; 109 | }; 110 | A4FAC6891A3ACF0400895556 /* HamiltonianTests */ = { 111 | isa = PBXGroup; 112 | children = ( 113 | A4FAC68C1A3ACF0400895556 /* HamiltonianTests.swift */, 114 | A4FAC68A1A3ACF0400895556 /* Supporting Files */, 115 | ); 116 | path = HamiltonianTests; 117 | sourceTree = ""; 118 | }; 119 | A4FAC68A1A3ACF0400895556 /* Supporting Files */ = { 120 | isa = PBXGroup; 121 | children = ( 122 | A4FAC68B1A3ACF0400895556 /* Info.plist */, 123 | ); 124 | name = "Supporting Files"; 125 | sourceTree = ""; 126 | }; 127 | A4FAC6961A3AD0B600895556 /* Views */ = { 128 | isa = PBXGroup; 129 | children = ( 130 | A4FAC6971A3AD0E600895556 /* Background.swift */, 131 | A4FAC6991A3AD10A00895556 /* PointView.swift */, 132 | ); 133 | name = Views; 134 | sourceTree = ""; 135 | }; 136 | A4FAC69B1A3AD14200895556 /* Algorithm */ = { 137 | isa = PBXGroup; 138 | children = ( 139 | A40E7B0E1A3B1BC30095A1A6 /* BaseTreeSearching.swift */, 140 | A48D84C41A3D45F600BB5B55 /* MySearching.swift */, 141 | A41C0FA51A3FFB98002DCF8D /* HillClimbingSearch.swift */, 142 | ); 143 | name = Algorithm; 144 | sourceTree = ""; 145 | }; 146 | A4FAC69C1A3AD15700895556 /* Utils */ = { 147 | isa = PBXGroup; 148 | children = ( 149 | A4FAC69D1A3AD1C200895556 /* HelpMethod.swift */, 150 | ); 151 | name = Utils; 152 | sourceTree = ""; 153 | }; 154 | /* End PBXGroup section */ 155 | 156 | /* Begin PBXNativeTarget section */ 157 | A4FAC6731A3ACF0400895556 /* Hamiltonian */ = { 158 | isa = PBXNativeTarget; 159 | buildConfigurationList = A4FAC6901A3ACF0400895556 /* Build configuration list for PBXNativeTarget "Hamiltonian" */; 160 | buildPhases = ( 161 | A4FAC6701A3ACF0400895556 /* Sources */, 162 | A4FAC6711A3ACF0400895556 /* Frameworks */, 163 | A4FAC6721A3ACF0400895556 /* Resources */, 164 | ); 165 | buildRules = ( 166 | ); 167 | dependencies = ( 168 | ); 169 | name = Hamiltonian; 170 | productName = Hamiltonian; 171 | productReference = A4FAC6741A3ACF0400895556 /* Hamiltonian.app */; 172 | productType = "com.apple.product-type.application"; 173 | }; 174 | A4FAC6851A3ACF0400895556 /* HamiltonianTests */ = { 175 | isa = PBXNativeTarget; 176 | buildConfigurationList = A4FAC6931A3ACF0400895556 /* Build configuration list for PBXNativeTarget "HamiltonianTests" */; 177 | buildPhases = ( 178 | A4FAC6821A3ACF0400895556 /* Sources */, 179 | A4FAC6831A3ACF0400895556 /* Frameworks */, 180 | A4FAC6841A3ACF0400895556 /* Resources */, 181 | ); 182 | buildRules = ( 183 | ); 184 | dependencies = ( 185 | A4FAC6881A3ACF0400895556 /* PBXTargetDependency */, 186 | ); 187 | name = HamiltonianTests; 188 | productName = HamiltonianTests; 189 | productReference = A4FAC6861A3ACF0400895556 /* HamiltonianTests.xctest */; 190 | productType = "com.apple.product-type.bundle.unit-test"; 191 | }; 192 | /* End PBXNativeTarget section */ 193 | 194 | /* Begin PBXProject section */ 195 | A4FAC66C1A3ACF0400895556 /* Project object */ = { 196 | isa = PBXProject; 197 | attributes = { 198 | LastSwiftMigration = 0700; 199 | LastSwiftUpdateCheck = 0700; 200 | LastUpgradeCheck = 0800; 201 | ORGANIZATIONNAME = "杨萧玉"; 202 | TargetAttributes = { 203 | A4FAC6731A3ACF0400895556 = { 204 | CreatedOnToolsVersion = 6.1.1; 205 | LastSwiftMigration = 0800; 206 | }; 207 | A4FAC6851A3ACF0400895556 = { 208 | CreatedOnToolsVersion = 6.1.1; 209 | LastSwiftMigration = 0800; 210 | TestTargetID = A4FAC6731A3ACF0400895556; 211 | }; 212 | }; 213 | }; 214 | buildConfigurationList = A4FAC66F1A3ACF0400895556 /* Build configuration list for PBXProject "Hamiltonian" */; 215 | compatibilityVersion = "Xcode 3.2"; 216 | developmentRegion = English; 217 | hasScannedForEncodings = 0; 218 | knownRegions = ( 219 | en, 220 | Base, 221 | ); 222 | mainGroup = A4FAC66B1A3ACF0400895556; 223 | productRefGroup = A4FAC6751A3ACF0400895556 /* Products */; 224 | projectDirPath = ""; 225 | projectRoot = ""; 226 | targets = ( 227 | A4FAC6731A3ACF0400895556 /* Hamiltonian */, 228 | A4FAC6851A3ACF0400895556 /* HamiltonianTests */, 229 | ); 230 | }; 231 | /* End PBXProject section */ 232 | 233 | /* Begin PBXResourcesBuildPhase section */ 234 | A4FAC6721A3ACF0400895556 /* Resources */ = { 235 | isa = PBXResourcesBuildPhase; 236 | buildActionMask = 2147483647; 237 | files = ( 238 | A4FAC67E1A3ACF0400895556 /* Images.xcassets in Resources */, 239 | A4FAC6811A3ACF0400895556 /* Main.storyboard in Resources */, 240 | ); 241 | runOnlyForDeploymentPostprocessing = 0; 242 | }; 243 | A4FAC6841A3ACF0400895556 /* Resources */ = { 244 | isa = PBXResourcesBuildPhase; 245 | buildActionMask = 2147483647; 246 | files = ( 247 | ); 248 | runOnlyForDeploymentPostprocessing = 0; 249 | }; 250 | /* End PBXResourcesBuildPhase section */ 251 | 252 | /* Begin PBXSourcesBuildPhase section */ 253 | A4FAC6701A3ACF0400895556 /* Sources */ = { 254 | isa = PBXSourcesBuildPhase; 255 | buildActionMask = 2147483647; 256 | files = ( 257 | A4FAC67C1A3ACF0400895556 /* ViewController.swift in Sources */, 258 | A4FAC67A1A3ACF0400895556 /* AppDelegate.swift in Sources */, 259 | A4FAC6981A3AD0E600895556 /* Background.swift in Sources */, 260 | A40E7B0F1A3B1BC30095A1A6 /* BaseTreeSearching.swift in Sources */, 261 | A4FAC69E1A3AD1C200895556 /* HelpMethod.swift in Sources */, 262 | A4FAC69A1A3AD10A00895556 /* PointView.swift in Sources */, 263 | A48D84C51A3D45F600BB5B55 /* MySearching.swift in Sources */, 264 | A41C0FA61A3FFB98002DCF8D /* HillClimbingSearch.swift in Sources */, 265 | ); 266 | runOnlyForDeploymentPostprocessing = 0; 267 | }; 268 | A4FAC6821A3ACF0400895556 /* Sources */ = { 269 | isa = PBXSourcesBuildPhase; 270 | buildActionMask = 2147483647; 271 | files = ( 272 | A4FAC68D1A3ACF0400895556 /* HamiltonianTests.swift in Sources */, 273 | ); 274 | runOnlyForDeploymentPostprocessing = 0; 275 | }; 276 | /* End PBXSourcesBuildPhase section */ 277 | 278 | /* Begin PBXTargetDependency section */ 279 | A4FAC6881A3ACF0400895556 /* PBXTargetDependency */ = { 280 | isa = PBXTargetDependency; 281 | target = A4FAC6731A3ACF0400895556 /* Hamiltonian */; 282 | targetProxy = A4FAC6871A3ACF0400895556 /* PBXContainerItemProxy */; 283 | }; 284 | /* End PBXTargetDependency section */ 285 | 286 | /* Begin PBXVariantGroup section */ 287 | A4FAC67F1A3ACF0400895556 /* Main.storyboard */ = { 288 | isa = PBXVariantGroup; 289 | children = ( 290 | A4FAC6801A3ACF0400895556 /* Base */, 291 | ); 292 | name = Main.storyboard; 293 | sourceTree = ""; 294 | }; 295 | /* End PBXVariantGroup section */ 296 | 297 | /* Begin XCBuildConfiguration section */ 298 | A4FAC68E1A3ACF0400895556 /* Debug */ = { 299 | isa = XCBuildConfiguration; 300 | buildSettings = { 301 | ALWAYS_SEARCH_USER_PATHS = NO; 302 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 303 | CLANG_CXX_LIBRARY = "libc++"; 304 | CLANG_ENABLE_MODULES = YES; 305 | CLANG_ENABLE_OBJC_ARC = YES; 306 | CLANG_WARN_BOOL_CONVERSION = YES; 307 | CLANG_WARN_CONSTANT_CONVERSION = YES; 308 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 309 | CLANG_WARN_EMPTY_BODY = YES; 310 | CLANG_WARN_ENUM_CONVERSION = YES; 311 | CLANG_WARN_INFINITE_RECURSION = YES; 312 | CLANG_WARN_INT_CONVERSION = YES; 313 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 314 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 315 | CLANG_WARN_UNREACHABLE_CODE = YES; 316 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 317 | CODE_SIGN_IDENTITY = "-"; 318 | COPY_PHASE_STRIP = NO; 319 | ENABLE_STRICT_OBJC_MSGSEND = YES; 320 | ENABLE_TESTABILITY = YES; 321 | GCC_C_LANGUAGE_STANDARD = gnu99; 322 | GCC_DYNAMIC_NO_PIC = NO; 323 | GCC_NO_COMMON_BLOCKS = YES; 324 | GCC_OPTIMIZATION_LEVEL = 0; 325 | GCC_PREPROCESSOR_DEFINITIONS = ( 326 | "DEBUG=1", 327 | "$(inherited)", 328 | ); 329 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 330 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 331 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 332 | GCC_WARN_UNDECLARED_SELECTOR = YES; 333 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 334 | GCC_WARN_UNUSED_FUNCTION = YES; 335 | GCC_WARN_UNUSED_VARIABLE = YES; 336 | MACOSX_DEPLOYMENT_TARGET = 10.10; 337 | MTL_ENABLE_DEBUG_INFO = YES; 338 | ONLY_ACTIVE_ARCH = YES; 339 | SDKROOT = macosx; 340 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 341 | }; 342 | name = Debug; 343 | }; 344 | A4FAC68F1A3ACF0400895556 /* Release */ = { 345 | isa = XCBuildConfiguration; 346 | buildSettings = { 347 | ALWAYS_SEARCH_USER_PATHS = NO; 348 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 349 | CLANG_CXX_LIBRARY = "libc++"; 350 | CLANG_ENABLE_MODULES = YES; 351 | CLANG_ENABLE_OBJC_ARC = YES; 352 | CLANG_WARN_BOOL_CONVERSION = YES; 353 | CLANG_WARN_CONSTANT_CONVERSION = YES; 354 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 355 | CLANG_WARN_EMPTY_BODY = YES; 356 | CLANG_WARN_ENUM_CONVERSION = YES; 357 | CLANG_WARN_INFINITE_RECURSION = YES; 358 | CLANG_WARN_INT_CONVERSION = YES; 359 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 360 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 361 | CLANG_WARN_UNREACHABLE_CODE = YES; 362 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 363 | CODE_SIGN_IDENTITY = "-"; 364 | COPY_PHASE_STRIP = YES; 365 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 366 | ENABLE_NS_ASSERTIONS = NO; 367 | ENABLE_STRICT_OBJC_MSGSEND = YES; 368 | GCC_C_LANGUAGE_STANDARD = gnu99; 369 | GCC_NO_COMMON_BLOCKS = YES; 370 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 371 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 372 | GCC_WARN_UNDECLARED_SELECTOR = YES; 373 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 374 | GCC_WARN_UNUSED_FUNCTION = YES; 375 | GCC_WARN_UNUSED_VARIABLE = YES; 376 | MACOSX_DEPLOYMENT_TARGET = 10.10; 377 | MTL_ENABLE_DEBUG_INFO = NO; 378 | SDKROOT = macosx; 379 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 380 | }; 381 | name = Release; 382 | }; 383 | A4FAC6911A3ACF0400895556 /* Debug */ = { 384 | isa = XCBuildConfiguration; 385 | buildSettings = { 386 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 387 | COMBINE_HIDPI_IMAGES = YES; 388 | INFOPLIST_FILE = Hamiltonian/Info.plist; 389 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; 390 | PRODUCT_BUNDLE_IDENTIFIER = "com.yxy.$(PRODUCT_NAME:rfc1034identifier)"; 391 | PRODUCT_NAME = "$(TARGET_NAME)"; 392 | SWIFT_VERSION = 3.0; 393 | }; 394 | name = Debug; 395 | }; 396 | A4FAC6921A3ACF0400895556 /* Release */ = { 397 | isa = XCBuildConfiguration; 398 | buildSettings = { 399 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 400 | COMBINE_HIDPI_IMAGES = YES; 401 | INFOPLIST_FILE = Hamiltonian/Info.plist; 402 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; 403 | PRODUCT_BUNDLE_IDENTIFIER = "com.yxy.$(PRODUCT_NAME:rfc1034identifier)"; 404 | PRODUCT_NAME = "$(TARGET_NAME)"; 405 | SWIFT_VERSION = 3.0; 406 | }; 407 | name = Release; 408 | }; 409 | A4FAC6941A3ACF0400895556 /* Debug */ = { 410 | isa = XCBuildConfiguration; 411 | buildSettings = { 412 | BUNDLE_LOADER = "$(TEST_HOST)"; 413 | COMBINE_HIDPI_IMAGES = YES; 414 | FRAMEWORK_SEARCH_PATHS = ( 415 | "$(DEVELOPER_FRAMEWORKS_DIR)", 416 | "$(inherited)", 417 | ); 418 | GCC_PREPROCESSOR_DEFINITIONS = ( 419 | "DEBUG=1", 420 | "$(inherited)", 421 | ); 422 | INFOPLIST_FILE = HamiltonianTests/Info.plist; 423 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; 424 | PRODUCT_BUNDLE_IDENTIFIER = "com.yxy.$(PRODUCT_NAME:rfc1034identifier)"; 425 | PRODUCT_NAME = "$(TARGET_NAME)"; 426 | SWIFT_VERSION = 3.0; 427 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Hamiltonian.app/Contents/MacOS/Hamiltonian"; 428 | }; 429 | name = Debug; 430 | }; 431 | A4FAC6951A3ACF0400895556 /* Release */ = { 432 | isa = XCBuildConfiguration; 433 | buildSettings = { 434 | BUNDLE_LOADER = "$(TEST_HOST)"; 435 | COMBINE_HIDPI_IMAGES = YES; 436 | FRAMEWORK_SEARCH_PATHS = ( 437 | "$(DEVELOPER_FRAMEWORKS_DIR)", 438 | "$(inherited)", 439 | ); 440 | INFOPLIST_FILE = HamiltonianTests/Info.plist; 441 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; 442 | PRODUCT_BUNDLE_IDENTIFIER = "com.yxy.$(PRODUCT_NAME:rfc1034identifier)"; 443 | PRODUCT_NAME = "$(TARGET_NAME)"; 444 | SWIFT_VERSION = 3.0; 445 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Hamiltonian.app/Contents/MacOS/Hamiltonian"; 446 | }; 447 | name = Release; 448 | }; 449 | /* End XCBuildConfiguration section */ 450 | 451 | /* Begin XCConfigurationList section */ 452 | A4FAC66F1A3ACF0400895556 /* Build configuration list for PBXProject "Hamiltonian" */ = { 453 | isa = XCConfigurationList; 454 | buildConfigurations = ( 455 | A4FAC68E1A3ACF0400895556 /* Debug */, 456 | A4FAC68F1A3ACF0400895556 /* Release */, 457 | ); 458 | defaultConfigurationIsVisible = 0; 459 | defaultConfigurationName = Release; 460 | }; 461 | A4FAC6901A3ACF0400895556 /* Build configuration list for PBXNativeTarget "Hamiltonian" */ = { 462 | isa = XCConfigurationList; 463 | buildConfigurations = ( 464 | A4FAC6911A3ACF0400895556 /* Debug */, 465 | A4FAC6921A3ACF0400895556 /* Release */, 466 | ); 467 | defaultConfigurationIsVisible = 0; 468 | defaultConfigurationName = Release; 469 | }; 470 | A4FAC6931A3ACF0400895556 /* Build configuration list for PBXNativeTarget "HamiltonianTests" */ = { 471 | isa = XCConfigurationList; 472 | buildConfigurations = ( 473 | A4FAC6941A3ACF0400895556 /* Debug */, 474 | A4FAC6951A3ACF0400895556 /* Release */, 475 | ); 476 | defaultConfigurationIsVisible = 0; 477 | defaultConfigurationName = Release; 478 | }; 479 | /* End XCConfigurationList section */ 480 | }; 481 | rootObject = A4FAC66C1A3ACF0400895556 /* Project object */; 482 | } 483 | -------------------------------------------------------------------------------- /Hamiltonian/Hamiltonian/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // Hamiltonian 4 | // 5 | // Created by 杨萧玉 on 14/12/12. 6 | // Copyright (c) 2014年 杨萧玉. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | 11 | @NSApplicationMain 12 | class AppDelegate: NSObject, NSApplicationDelegate { 13 | 14 | 15 | 16 | func applicationDidFinishLaunching(_ aNotification: Notification) { 17 | // Insert code here to initialize your application 18 | } 19 | 20 | func applicationWillTerminate(_ aNotification: Notification) { 21 | // Insert code here to tear down your application 22 | } 23 | 24 | 25 | } 26 | 27 | -------------------------------------------------------------------------------- /Hamiltonian/Hamiltonian/Background.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Background.swift 3 | // ConvexHull 4 | // 5 | // Created by 杨萧玉 on 14/11/24. 6 | // Copyright (c) 2014年 杨萧玉. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | import AppKit 11 | 12 | class Background: NSView, ChooseAlgorithm { 13 | 14 | @IBOutlet weak var costTimeLabel: NSTextField! 15 | var points:[PointView] = [] 16 | var result:[PointView]? 17 | var generator:HamiltonianGenerator? 18 | var algorithmSelected:Algorithm = Algorithm.baseTreeSearch { 19 | willSet{ 20 | switch newValue { 21 | case .baseTreeSearch: 22 | generator = BaseTreeSearching() 23 | case .hillClimbing: 24 | generator = HillClimbingSearch() 25 | case .mySearch: 26 | generator = MySearching() 27 | } 28 | makeHamiltonian() 29 | } 30 | } 31 | var pointNumSelected:UInt32 = 0 { 32 | willSet{ 33 | createPointsWithNum(newValue) 34 | makeHamiltonian() 35 | } 36 | } 37 | 38 | var size:CGSize! 39 | var linking:Bool = false { 40 | willSet{ 41 | if !newValue { 42 | linkDestination = linkBlock() 43 | } 44 | else { 45 | linkSource = linkBlock() 46 | } 47 | } 48 | didSet{ 49 | if !linking { 50 | linkDestination?.neighbours.add(linkSource!) 51 | linkSource?.neighbours.add(linkDestination!) 52 | linkSource = nil 53 | linkDestination = nil 54 | } 55 | } 56 | } 57 | var linkSource:PointView? 58 | var linkDestination:PointView? 59 | var linkBlock:()->PointView? = {return nil} 60 | override func draw(_ dirtyRect: NSRect) { 61 | super.draw(dirtyRect) 62 | if points.isEmpty { 63 | return 64 | } 65 | 66 | let path = CGMutablePath() 67 | for point in points { 68 | for neighbour in point.neighbours { 69 | path.move(to: CGPoint(x: point.position.x, y: point.position.y)) 70 | path.addLine(to: CGPoint(x: (neighbour as AnyObject).position.x, y: (neighbour as AnyObject).position.y)) 71 | } 72 | } 73 | 74 | 75 | let context = NSGraphicsContext.current()?.cgContext 76 | context?.clear(NSRect(origin: CGPoint.zero, size: frame.size)) 77 | context?.addPath(path) 78 | context?.setLineJoin(CGLineJoin.round) 79 | context?.setLineCap(CGLineCap.round) 80 | context?.setLineWidth(5.0) 81 | NSColor.red.setStroke() 82 | context?.drawPath(using: CGPathDrawingMode.stroke) 83 | 84 | let hamiltonianPath = CGMutablePath() 85 | var locations:[CGPoint] = [] 86 | if result != nil { 87 | for point in result! { 88 | locations.append(point.position) 89 | } 90 | } 91 | hamiltonianPath.addLines(between: locations) 92 | if !locations.isEmpty { 93 | hamiltonianPath.closeSubpath() 94 | } 95 | context?.addPath(hamiltonianPath) 96 | NSColor.green.setStroke() 97 | context?.drawPath(using: CGPathDrawingMode.stroke) 98 | } 99 | 100 | override func viewWillMove(toWindow newWindow: NSWindow?) { 101 | super.viewWillMove(toWindow: newWindow) 102 | size = newWindow?.frame.size 103 | algorithmSelected = Algorithm.baseTreeSearch 104 | } 105 | 106 | override func mouseUp(with theEvent: NSEvent) { 107 | if theEvent.clickCount > 1 { 108 | let location = convert(theEvent.locationInWindow, from: nil) 109 | addPont(location) 110 | makeHamiltonian() 111 | } 112 | } 113 | 114 | func addPont(_ location:CGPoint) { 115 | let pointView = PointView(location: location) 116 | points.append(pointView) 117 | addSubview(pointView) 118 | } 119 | 120 | func clearPoints() { 121 | for point in points { 122 | point.removeFromSuperview() 123 | } 124 | points.removeAll(keepingCapacity: false) 125 | } 126 | 127 | func makeHamiltonian(){ 128 | result = generator?.generateHamiltonian(&points) 129 | if let cost = generator?.costTime { 130 | (costTimeLabel.cell as! NSTextFieldCell).title = "\(cost*1000)" 131 | } 132 | else{ 133 | (costTimeLabel.cell as! NSTextFieldCell).title = "运行时间" 134 | } 135 | setNeedsDisplay(frame) 136 | } 137 | 138 | 139 | 140 | func createPointsWithNum(_ num:UInt32) { 141 | clearPoints() 142 | for _ in 0..Bool = {return true} 23 | func generateHamiltonian(_ points:inout [PointView])->[PointView] { 24 | self.points = points 25 | beginTime = Date() 26 | success = false 27 | sortedPoints.removeAll(keepingCapacity: false) 28 | if preprocessor() { 29 | if points.count>0 { 30 | backtracking(points, neighbour: points[0]) 31 | } 32 | } 33 | endTime = Date() 34 | return sortedPoints 35 | } 36 | 37 | func backtracking(_ points:[PointView],neighbour:PointView) { 38 | sortedPoints.append(neighbour) 39 | neighbour.image = NSImage(named: "RedPoint") 40 | for point in sortedPoints.last!.neighbours { 41 | if (point as! PointView).position == sortedPoints[0].position { 42 | if sortedPoints.count == points.count { 43 | success = true 44 | return 45 | } 46 | else { 47 | continue 48 | } 49 | } 50 | else if checkPoint(point as! PointView, inPoints: sortedPoints) { 51 | continue 52 | } 53 | else { 54 | backtracking(points, neighbour: point as! PointView) 55 | } 56 | } 57 | if !success { 58 | sortedPoints.last!.image = NSImage(named: "point") 59 | sortedPoints.removeLast() 60 | } 61 | } 62 | 63 | func checkPoint(_ aPoint:PointView,inPoints points:[PointView])->Bool { 64 | for point in points { 65 | if point.position == aPoint.position { 66 | return true; 67 | } 68 | } 69 | return false 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /Hamiltonian/Hamiltonian/HelpMethod.swift: -------------------------------------------------------------------------------- 1 | // 2 | // HelpMethod.swift 3 | // Hamiltonian 4 | // 5 | // Created by 杨萧玉 on 14/12/12. 6 | // Copyright (c) 2014年 杨萧玉. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | 11 | protocol HamiltonianGenerator: class{ 12 | var beginTime:Date{get set} 13 | var endTime:Date{get set} 14 | var costTime:TimeInterval{get} 15 | func generateHamiltonian(_ points:inout [PointView])->[PointView] 16 | } 17 | 18 | protocol ChooseAlgorithm { 19 | var algorithmSelected:Algorithm {get set} 20 | } 21 | 22 | enum Algorithm { 23 | case baseTreeSearch 24 | case hillClimbing 25 | case mySearch 26 | } 27 | 28 | -------------------------------------------------------------------------------- /Hamiltonian/Hamiltonian/HillClimbingSearch.swift: -------------------------------------------------------------------------------- 1 | // 2 | // HillClimbingSearch.swift 3 | // Hamiltonian 4 | // 5 | // Created by 杨萧玉 on 14/12/16. 6 | // Copyright (c) 2014年 杨萧玉. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | 11 | class HillClimbingSearch: BaseTreeSearching { 12 | override init(){ 13 | super.init() 14 | preprocessor = { ()->Bool in 15 | self.points.sort(by: { (a, b) -> Bool in 16 | return a.neighbours.count < b.neighbours.count 17 | }) 18 | return true 19 | } 20 | } 21 | override func backtracking(_ points: [PointView], neighbour: PointView) { 22 | sortedPoints.append(neighbour) 23 | neighbour.image = NSImage(named: "RedPoint") 24 | let sortedSet = sortedPoints.last!.neighbours.sortedArray(using: [NSSortDescriptor(key: "neighbours", ascending: true, comparator: { (a, b) -> ComparisonResult in 25 | if (a as! NSMutableSet).count < (b as! NSMutableSet).count { 26 | return .orderedAscending 27 | } 28 | else if (a as! NSMutableSet).count > (b as! NSMutableSet).count{ 29 | return .orderedDescending 30 | } 31 | else{ 32 | return .orderedSame 33 | } 34 | })]) 35 | if (sortedSet as? [PointView] != nil){ 36 | for point in sortedSet { 37 | if (point as AnyObject).position == sortedPoints[0].position { 38 | if sortedPoints.count == points.count { 39 | success = true 40 | return 41 | } 42 | else { 43 | continue 44 | } 45 | } 46 | else if checkPoint(point as! PointView, inPoints: sortedPoints) { 47 | continue 48 | } 49 | else { 50 | backtracking(points, neighbour: point as! PointView) 51 | } 52 | } 53 | } 54 | if !success { 55 | sortedPoints.last!.image = NSImage(named: "point") 56 | sortedPoints.removeLast() 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /Hamiltonian/Hamiltonian/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "mac", 5 | "size" : "16x16", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "mac", 10 | "size" : "16x16", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "mac", 15 | "size" : "32x32", 16 | "scale" : "1x" 17 | }, 18 | { 19 | "idiom" : "mac", 20 | "size" : "32x32", 21 | "scale" : "2x" 22 | }, 23 | { 24 | "idiom" : "mac", 25 | "size" : "128x128", 26 | "scale" : "1x" 27 | }, 28 | { 29 | "idiom" : "mac", 30 | "size" : "128x128", 31 | "scale" : "2x" 32 | }, 33 | { 34 | "idiom" : "mac", 35 | "size" : "256x256", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "mac", 40 | "size" : "256x256", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "mac", 45 | "size" : "512x512", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "mac", 50 | "size" : "512x512", 51 | "scale" : "2x" 52 | } 53 | ], 54 | "info" : { 55 | "version" : 1, 56 | "author" : "xcode" 57 | } 58 | } -------------------------------------------------------------------------------- /Hamiltonian/Hamiltonian/Images.xcassets/RedPoint.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "scale" : "2x", 10 | "filename" : "RedPoint.png" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /Hamiltonian/Hamiltonian/Images.xcassets/RedPoint.imageset/RedPoint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yulingtianxia/Algorithm-Experiment/d747bdf492ca40372beaa0169b36d3098365cd09/Hamiltonian/Hamiltonian/Images.xcassets/RedPoint.imageset/RedPoint.png -------------------------------------------------------------------------------- /Hamiltonian/Hamiltonian/Images.xcassets/point.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "scale" : "2x", 10 | "filename" : "point.png" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /Hamiltonian/Hamiltonian/Images.xcassets/point.imageset/point.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yulingtianxia/Algorithm-Experiment/d747bdf492ca40372beaa0169b36d3098365cd09/Hamiltonian/Hamiltonian/Images.xcassets/point.imageset/point.png -------------------------------------------------------------------------------- /Hamiltonian/Hamiltonian/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSMinimumSystemVersion 26 | $(MACOSX_DEPLOYMENT_TARGET) 27 | NSHumanReadableCopyright 28 | Copyright © 2014年 杨萧玉. All rights reserved. 29 | NSMainStoryboardFile 30 | Main 31 | NSPrincipalClass 32 | NSApplication 33 | 34 | 35 | -------------------------------------------------------------------------------- /Hamiltonian/Hamiltonian/MySearching.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MySearching.swift 3 | // Hamiltonian 4 | // 5 | // Created by 杨萧玉 on 14/12/14. 6 | // Copyright (c) 2014年 杨萧玉. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | 11 | class MySearching: BaseTreeSearching { 12 | override init(){ 13 | super.init() 14 | preprocessor = { ()->Bool in 15 | for point in self.points { 16 | if point.neighbours.count <= 1 { 17 | return false 18 | } 19 | } 20 | return true 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Hamiltonian/Hamiltonian/PointView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PointView.swift 3 | // ConvexHull 4 | // 5 | // Created by 杨萧玉 on 14/11/25. 6 | // Copyright (c) 2014年 杨萧玉. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | 11 | private let length:CGFloat = 25 12 | 13 | class PointView: NSImageView { 14 | 15 | var position:CGPoint { 16 | set{ 17 | frame.origin = CGPoint(x: newValue.x - length/2, y: newValue.y - length/2) 18 | } 19 | get{ 20 | return CGPoint(x: frame.origin.x + length/2, y: frame.origin.y + length/2) 21 | } 22 | } 23 | 24 | var neighbours:NSMutableSet = NSMutableSet() 25 | 26 | override func draw(_ dirtyRect: NSRect) { 27 | super.draw(dirtyRect) 28 | 29 | // Drawing code here. 30 | } 31 | 32 | init(location:CGPoint) { 33 | super.init(frame: NSRect(x: location.x - length/2, y: location.y - length/2, width: length, height: length)) 34 | image = NSImage(named: "point") 35 | } 36 | 37 | required init?(coder: NSCoder) { 38 | fatalError("init(coder:) has not been implemented") 39 | } 40 | 41 | override func mouseDragged(with theEvent: NSEvent) { 42 | // let delta = convertPoint(theEvent.locationInWindow, fromView: nil) 43 | if let location = superview?.convert(theEvent.locationInWindow, from: nil) { 44 | position = location 45 | (superview as? Background)?.setNeedsDisplay(superview!.frame) 46 | } 47 | } 48 | 49 | override func rightMouseUp(with theEvent: NSEvent) { 50 | if (superview as! Background).linking { 51 | (superview as! Background).linkBlock = {self} 52 | (superview as! Background).linking = false 53 | (superview as? Background)?.makeHamiltonian() 54 | } 55 | else{ 56 | (superview as! Background).linkBlock = {self} 57 | (superview as! Background).linking = true 58 | } 59 | } 60 | 61 | 62 | } 63 | -------------------------------------------------------------------------------- /Hamiltonian/Hamiltonian/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // Hamiltonian 4 | // 5 | // Created by 杨萧玉 on 14/12/12. 6 | // Copyright (c) 2014年 杨萧玉. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | 11 | class ViewController: NSViewController { 12 | 13 | override func viewDidLoad() { 14 | super.viewDidLoad() 15 | 16 | // Do any additional setup after loading the view. 17 | } 18 | 19 | override var representedObject: Any? { 20 | didSet { 21 | // Update the view, if already loaded. 22 | } 23 | } 24 | 25 | 26 | } 27 | 28 | -------------------------------------------------------------------------------- /Hamiltonian/HamiltonianTests/HamiltonianTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // HamiltonianTests.swift 3 | // HamiltonianTests 4 | // 5 | // Created by 杨萧玉 on 14/12/12. 6 | // Copyright (c) 2014年 杨萧玉. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | import XCTest 11 | 12 | class HamiltonianTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testExample() { 25 | // This is an example of a functional test case. 26 | XCTAssert(true, "Pass") 27 | } 28 | 29 | func testPerformanceExample() { 30 | // This is an example of a performance test case. 31 | self.measure() { 32 | // Put the code you want to measure the time of here. 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /Hamiltonian/HamiltonianTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /LCS/LCS.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | A410A97C1A2DB14B007C260E /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = A410A97B1A2DB14B007C260E /* AppDelegate.swift */; }; 11 | A410A97E1A2DB14B007C260E /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A410A97D1A2DB14B007C260E /* ViewController.swift */; }; 12 | A410A9801A2DB14B007C260E /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A410A97F1A2DB14B007C260E /* Images.xcassets */; }; 13 | A410A9831A2DB14B007C260E /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A410A9811A2DB14B007C260E /* Main.storyboard */; }; 14 | A410A98F1A2DB14B007C260E /* LCSTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A410A98E1A2DB14B007C260E /* LCSTests.swift */; }; 15 | A410A9991A2DB4FE007C260E /* Background.swift in Sources */ = {isa = PBXBuildFile; fileRef = A410A9981A2DB4FE007C260E /* Background.swift */; }; 16 | A410A99B1A2DB63A007C260E /* LCS.swift in Sources */ = {isa = PBXBuildFile; fileRef = A410A99A1A2DB63A007C260E /* LCS.swift */; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXContainerItemProxy section */ 20 | A410A9891A2DB14B007C260E /* PBXContainerItemProxy */ = { 21 | isa = PBXContainerItemProxy; 22 | containerPortal = A410A96E1A2DB14B007C260E /* Project object */; 23 | proxyType = 1; 24 | remoteGlobalIDString = A410A9751A2DB14B007C260E; 25 | remoteInfo = LCS; 26 | }; 27 | /* End PBXContainerItemProxy section */ 28 | 29 | /* Begin PBXFileReference section */ 30 | A410A9761A2DB14B007C260E /* LCS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = LCS.app; sourceTree = BUILT_PRODUCTS_DIR; }; 31 | A410A97A1A2DB14B007C260E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 32 | A410A97B1A2DB14B007C260E /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 33 | A410A97D1A2DB14B007C260E /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 34 | A410A97F1A2DB14B007C260E /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 35 | A410A9821A2DB14B007C260E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 36 | A410A9881A2DB14B007C260E /* LCSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = LCSTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 37 | A410A98D1A2DB14B007C260E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 38 | A410A98E1A2DB14B007C260E /* LCSTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LCSTests.swift; sourceTree = ""; }; 39 | A410A9981A2DB4FE007C260E /* Background.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Background.swift; sourceTree = ""; }; 40 | A410A99A1A2DB63A007C260E /* LCS.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LCS.swift; sourceTree = ""; }; 41 | /* End PBXFileReference section */ 42 | 43 | /* Begin PBXFrameworksBuildPhase section */ 44 | A410A9731A2DB14B007C260E /* Frameworks */ = { 45 | isa = PBXFrameworksBuildPhase; 46 | buildActionMask = 2147483647; 47 | files = ( 48 | ); 49 | runOnlyForDeploymentPostprocessing = 0; 50 | }; 51 | A410A9851A2DB14B007C260E /* Frameworks */ = { 52 | isa = PBXFrameworksBuildPhase; 53 | buildActionMask = 2147483647; 54 | files = ( 55 | ); 56 | runOnlyForDeploymentPostprocessing = 0; 57 | }; 58 | /* End PBXFrameworksBuildPhase section */ 59 | 60 | /* Begin PBXGroup section */ 61 | A410A96D1A2DB14B007C260E = { 62 | isa = PBXGroup; 63 | children = ( 64 | A410A9781A2DB14B007C260E /* LCS */, 65 | A410A98B1A2DB14B007C260E /* LCSTests */, 66 | A410A9771A2DB14B007C260E /* Products */, 67 | ); 68 | sourceTree = ""; 69 | }; 70 | A410A9771A2DB14B007C260E /* Products */ = { 71 | isa = PBXGroup; 72 | children = ( 73 | A410A9761A2DB14B007C260E /* LCS.app */, 74 | A410A9881A2DB14B007C260E /* LCSTests.xctest */, 75 | ); 76 | name = Products; 77 | sourceTree = ""; 78 | }; 79 | A410A9781A2DB14B007C260E /* LCS */ = { 80 | isa = PBXGroup; 81 | children = ( 82 | A410A97B1A2DB14B007C260E /* AppDelegate.swift */, 83 | A410A99A1A2DB63A007C260E /* LCS.swift */, 84 | A410A9981A2DB4FE007C260E /* Background.swift */, 85 | A410A97D1A2DB14B007C260E /* ViewController.swift */, 86 | A410A97F1A2DB14B007C260E /* Images.xcassets */, 87 | A410A9811A2DB14B007C260E /* Main.storyboard */, 88 | A410A9791A2DB14B007C260E /* Supporting Files */, 89 | ); 90 | path = LCS; 91 | sourceTree = ""; 92 | }; 93 | A410A9791A2DB14B007C260E /* Supporting Files */ = { 94 | isa = PBXGroup; 95 | children = ( 96 | A410A97A1A2DB14B007C260E /* Info.plist */, 97 | ); 98 | name = "Supporting Files"; 99 | sourceTree = ""; 100 | }; 101 | A410A98B1A2DB14B007C260E /* LCSTests */ = { 102 | isa = PBXGroup; 103 | children = ( 104 | A410A98E1A2DB14B007C260E /* LCSTests.swift */, 105 | A410A98C1A2DB14B007C260E /* Supporting Files */, 106 | ); 107 | path = LCSTests; 108 | sourceTree = ""; 109 | }; 110 | A410A98C1A2DB14B007C260E /* Supporting Files */ = { 111 | isa = PBXGroup; 112 | children = ( 113 | A410A98D1A2DB14B007C260E /* Info.plist */, 114 | ); 115 | name = "Supporting Files"; 116 | sourceTree = ""; 117 | }; 118 | /* End PBXGroup section */ 119 | 120 | /* Begin PBXNativeTarget section */ 121 | A410A9751A2DB14B007C260E /* LCS */ = { 122 | isa = PBXNativeTarget; 123 | buildConfigurationList = A410A9921A2DB14B007C260E /* Build configuration list for PBXNativeTarget "LCS" */; 124 | buildPhases = ( 125 | A410A9721A2DB14B007C260E /* Sources */, 126 | A410A9731A2DB14B007C260E /* Frameworks */, 127 | A410A9741A2DB14B007C260E /* Resources */, 128 | ); 129 | buildRules = ( 130 | ); 131 | dependencies = ( 132 | ); 133 | name = LCS; 134 | productName = LCS; 135 | productReference = A410A9761A2DB14B007C260E /* LCS.app */; 136 | productType = "com.apple.product-type.application"; 137 | }; 138 | A410A9871A2DB14B007C260E /* LCSTests */ = { 139 | isa = PBXNativeTarget; 140 | buildConfigurationList = A410A9951A2DB14B007C260E /* Build configuration list for PBXNativeTarget "LCSTests" */; 141 | buildPhases = ( 142 | A410A9841A2DB14B007C260E /* Sources */, 143 | A410A9851A2DB14B007C260E /* Frameworks */, 144 | A410A9861A2DB14B007C260E /* Resources */, 145 | ); 146 | buildRules = ( 147 | ); 148 | dependencies = ( 149 | A410A98A1A2DB14B007C260E /* PBXTargetDependency */, 150 | ); 151 | name = LCSTests; 152 | productName = LCSTests; 153 | productReference = A410A9881A2DB14B007C260E /* LCSTests.xctest */; 154 | productType = "com.apple.product-type.bundle.unit-test"; 155 | }; 156 | /* End PBXNativeTarget section */ 157 | 158 | /* Begin PBXProject section */ 159 | A410A96E1A2DB14B007C260E /* Project object */ = { 160 | isa = PBXProject; 161 | attributes = { 162 | LastSwiftMigration = 0700; 163 | LastSwiftUpdateCheck = 0700; 164 | LastUpgradeCheck = 0800; 165 | ORGANIZATIONNAME = "杨萧玉"; 166 | TargetAttributes = { 167 | A410A9751A2DB14B007C260E = { 168 | CreatedOnToolsVersion = 6.1; 169 | LastSwiftMigration = 0800; 170 | }; 171 | A410A9871A2DB14B007C260E = { 172 | CreatedOnToolsVersion = 6.1; 173 | LastSwiftMigration = 0800; 174 | TestTargetID = A410A9751A2DB14B007C260E; 175 | }; 176 | }; 177 | }; 178 | buildConfigurationList = A410A9711A2DB14B007C260E /* Build configuration list for PBXProject "LCS" */; 179 | compatibilityVersion = "Xcode 3.2"; 180 | developmentRegion = English; 181 | hasScannedForEncodings = 0; 182 | knownRegions = ( 183 | en, 184 | Base, 185 | ); 186 | mainGroup = A410A96D1A2DB14B007C260E; 187 | productRefGroup = A410A9771A2DB14B007C260E /* Products */; 188 | projectDirPath = ""; 189 | projectRoot = ""; 190 | targets = ( 191 | A410A9751A2DB14B007C260E /* LCS */, 192 | A410A9871A2DB14B007C260E /* LCSTests */, 193 | ); 194 | }; 195 | /* End PBXProject section */ 196 | 197 | /* Begin PBXResourcesBuildPhase section */ 198 | A410A9741A2DB14B007C260E /* Resources */ = { 199 | isa = PBXResourcesBuildPhase; 200 | buildActionMask = 2147483647; 201 | files = ( 202 | A410A9801A2DB14B007C260E /* Images.xcassets in Resources */, 203 | A410A9831A2DB14B007C260E /* Main.storyboard in Resources */, 204 | ); 205 | runOnlyForDeploymentPostprocessing = 0; 206 | }; 207 | A410A9861A2DB14B007C260E /* Resources */ = { 208 | isa = PBXResourcesBuildPhase; 209 | buildActionMask = 2147483647; 210 | files = ( 211 | ); 212 | runOnlyForDeploymentPostprocessing = 0; 213 | }; 214 | /* End PBXResourcesBuildPhase section */ 215 | 216 | /* Begin PBXSourcesBuildPhase section */ 217 | A410A9721A2DB14B007C260E /* Sources */ = { 218 | isa = PBXSourcesBuildPhase; 219 | buildActionMask = 2147483647; 220 | files = ( 221 | A410A97E1A2DB14B007C260E /* ViewController.swift in Sources */, 222 | A410A97C1A2DB14B007C260E /* AppDelegate.swift in Sources */, 223 | A410A99B1A2DB63A007C260E /* LCS.swift in Sources */, 224 | A410A9991A2DB4FE007C260E /* Background.swift in Sources */, 225 | ); 226 | runOnlyForDeploymentPostprocessing = 0; 227 | }; 228 | A410A9841A2DB14B007C260E /* Sources */ = { 229 | isa = PBXSourcesBuildPhase; 230 | buildActionMask = 2147483647; 231 | files = ( 232 | A410A98F1A2DB14B007C260E /* LCSTests.swift in Sources */, 233 | ); 234 | runOnlyForDeploymentPostprocessing = 0; 235 | }; 236 | /* End PBXSourcesBuildPhase section */ 237 | 238 | /* Begin PBXTargetDependency section */ 239 | A410A98A1A2DB14B007C260E /* PBXTargetDependency */ = { 240 | isa = PBXTargetDependency; 241 | target = A410A9751A2DB14B007C260E /* LCS */; 242 | targetProxy = A410A9891A2DB14B007C260E /* PBXContainerItemProxy */; 243 | }; 244 | /* End PBXTargetDependency section */ 245 | 246 | /* Begin PBXVariantGroup section */ 247 | A410A9811A2DB14B007C260E /* Main.storyboard */ = { 248 | isa = PBXVariantGroup; 249 | children = ( 250 | A410A9821A2DB14B007C260E /* Base */, 251 | ); 252 | name = Main.storyboard; 253 | sourceTree = ""; 254 | }; 255 | /* End PBXVariantGroup section */ 256 | 257 | /* Begin XCBuildConfiguration section */ 258 | A410A9901A2DB14B007C260E /* Debug */ = { 259 | isa = XCBuildConfiguration; 260 | buildSettings = { 261 | ALWAYS_SEARCH_USER_PATHS = NO; 262 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 263 | CLANG_CXX_LIBRARY = "libc++"; 264 | CLANG_ENABLE_MODULES = YES; 265 | CLANG_ENABLE_OBJC_ARC = YES; 266 | CLANG_WARN_BOOL_CONVERSION = YES; 267 | CLANG_WARN_CONSTANT_CONVERSION = YES; 268 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 269 | CLANG_WARN_EMPTY_BODY = YES; 270 | CLANG_WARN_ENUM_CONVERSION = YES; 271 | CLANG_WARN_INFINITE_RECURSION = YES; 272 | CLANG_WARN_INT_CONVERSION = YES; 273 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 274 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 275 | CLANG_WARN_UNREACHABLE_CODE = YES; 276 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 277 | CODE_SIGN_IDENTITY = "-"; 278 | COPY_PHASE_STRIP = NO; 279 | ENABLE_STRICT_OBJC_MSGSEND = YES; 280 | ENABLE_TESTABILITY = YES; 281 | GCC_C_LANGUAGE_STANDARD = gnu99; 282 | GCC_DYNAMIC_NO_PIC = NO; 283 | GCC_NO_COMMON_BLOCKS = YES; 284 | GCC_OPTIMIZATION_LEVEL = 0; 285 | GCC_PREPROCESSOR_DEFINITIONS = ( 286 | "DEBUG=1", 287 | "$(inherited)", 288 | ); 289 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 290 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 291 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 292 | GCC_WARN_UNDECLARED_SELECTOR = YES; 293 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 294 | GCC_WARN_UNUSED_FUNCTION = YES; 295 | GCC_WARN_UNUSED_VARIABLE = YES; 296 | MACOSX_DEPLOYMENT_TARGET = 10.10; 297 | MTL_ENABLE_DEBUG_INFO = YES; 298 | ONLY_ACTIVE_ARCH = YES; 299 | SDKROOT = macosx; 300 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 301 | }; 302 | name = Debug; 303 | }; 304 | A410A9911A2DB14B007C260E /* Release */ = { 305 | isa = XCBuildConfiguration; 306 | buildSettings = { 307 | ALWAYS_SEARCH_USER_PATHS = NO; 308 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 309 | CLANG_CXX_LIBRARY = "libc++"; 310 | CLANG_ENABLE_MODULES = YES; 311 | CLANG_ENABLE_OBJC_ARC = YES; 312 | CLANG_WARN_BOOL_CONVERSION = YES; 313 | CLANG_WARN_CONSTANT_CONVERSION = YES; 314 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 315 | CLANG_WARN_EMPTY_BODY = YES; 316 | CLANG_WARN_ENUM_CONVERSION = YES; 317 | CLANG_WARN_INFINITE_RECURSION = YES; 318 | CLANG_WARN_INT_CONVERSION = YES; 319 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 320 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 321 | CLANG_WARN_UNREACHABLE_CODE = YES; 322 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 323 | CODE_SIGN_IDENTITY = "-"; 324 | COPY_PHASE_STRIP = YES; 325 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 326 | ENABLE_NS_ASSERTIONS = NO; 327 | ENABLE_STRICT_OBJC_MSGSEND = YES; 328 | GCC_C_LANGUAGE_STANDARD = gnu99; 329 | GCC_NO_COMMON_BLOCKS = YES; 330 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 331 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 332 | GCC_WARN_UNDECLARED_SELECTOR = YES; 333 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 334 | GCC_WARN_UNUSED_FUNCTION = YES; 335 | GCC_WARN_UNUSED_VARIABLE = YES; 336 | MACOSX_DEPLOYMENT_TARGET = 10.10; 337 | MTL_ENABLE_DEBUG_INFO = NO; 338 | SDKROOT = macosx; 339 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 340 | }; 341 | name = Release; 342 | }; 343 | A410A9931A2DB14B007C260E /* Debug */ = { 344 | isa = XCBuildConfiguration; 345 | buildSettings = { 346 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 347 | COMBINE_HIDPI_IMAGES = YES; 348 | INFOPLIST_FILE = LCS/Info.plist; 349 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; 350 | PRODUCT_BUNDLE_IDENTIFIER = "com.yxy.$(PRODUCT_NAME:rfc1034identifier)"; 351 | PRODUCT_NAME = "$(TARGET_NAME)"; 352 | SWIFT_VERSION = 3.0; 353 | }; 354 | name = Debug; 355 | }; 356 | A410A9941A2DB14B007C260E /* Release */ = { 357 | isa = XCBuildConfiguration; 358 | buildSettings = { 359 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 360 | COMBINE_HIDPI_IMAGES = YES; 361 | INFOPLIST_FILE = LCS/Info.plist; 362 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; 363 | PRODUCT_BUNDLE_IDENTIFIER = "com.yxy.$(PRODUCT_NAME:rfc1034identifier)"; 364 | PRODUCT_NAME = "$(TARGET_NAME)"; 365 | SWIFT_VERSION = 3.0; 366 | }; 367 | name = Release; 368 | }; 369 | A410A9961A2DB14B007C260E /* Debug */ = { 370 | isa = XCBuildConfiguration; 371 | buildSettings = { 372 | BUNDLE_LOADER = "$(TEST_HOST)"; 373 | COMBINE_HIDPI_IMAGES = YES; 374 | FRAMEWORK_SEARCH_PATHS = ( 375 | "$(DEVELOPER_FRAMEWORKS_DIR)", 376 | "$(inherited)", 377 | ); 378 | GCC_PREPROCESSOR_DEFINITIONS = ( 379 | "DEBUG=1", 380 | "$(inherited)", 381 | ); 382 | INFOPLIST_FILE = LCSTests/Info.plist; 383 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; 384 | PRODUCT_BUNDLE_IDENTIFIER = "com.yxy.$(PRODUCT_NAME:rfc1034identifier)"; 385 | PRODUCT_NAME = "$(TARGET_NAME)"; 386 | SWIFT_VERSION = 3.0; 387 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/LCS.app/Contents/MacOS/LCS"; 388 | }; 389 | name = Debug; 390 | }; 391 | A410A9971A2DB14B007C260E /* Release */ = { 392 | isa = XCBuildConfiguration; 393 | buildSettings = { 394 | BUNDLE_LOADER = "$(TEST_HOST)"; 395 | COMBINE_HIDPI_IMAGES = YES; 396 | FRAMEWORK_SEARCH_PATHS = ( 397 | "$(DEVELOPER_FRAMEWORKS_DIR)", 398 | "$(inherited)", 399 | ); 400 | INFOPLIST_FILE = LCSTests/Info.plist; 401 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; 402 | PRODUCT_BUNDLE_IDENTIFIER = "com.yxy.$(PRODUCT_NAME:rfc1034identifier)"; 403 | PRODUCT_NAME = "$(TARGET_NAME)"; 404 | SWIFT_VERSION = 3.0; 405 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/LCS.app/Contents/MacOS/LCS"; 406 | }; 407 | name = Release; 408 | }; 409 | /* End XCBuildConfiguration section */ 410 | 411 | /* Begin XCConfigurationList section */ 412 | A410A9711A2DB14B007C260E /* Build configuration list for PBXProject "LCS" */ = { 413 | isa = XCConfigurationList; 414 | buildConfigurations = ( 415 | A410A9901A2DB14B007C260E /* Debug */, 416 | A410A9911A2DB14B007C260E /* Release */, 417 | ); 418 | defaultConfigurationIsVisible = 0; 419 | defaultConfigurationName = Release; 420 | }; 421 | A410A9921A2DB14B007C260E /* Build configuration list for PBXNativeTarget "LCS" */ = { 422 | isa = XCConfigurationList; 423 | buildConfigurations = ( 424 | A410A9931A2DB14B007C260E /* Debug */, 425 | A410A9941A2DB14B007C260E /* Release */, 426 | ); 427 | defaultConfigurationIsVisible = 0; 428 | defaultConfigurationName = Release; 429 | }; 430 | A410A9951A2DB14B007C260E /* Build configuration list for PBXNativeTarget "LCSTests" */ = { 431 | isa = XCConfigurationList; 432 | buildConfigurations = ( 433 | A410A9961A2DB14B007C260E /* Debug */, 434 | A410A9971A2DB14B007C260E /* Release */, 435 | ); 436 | defaultConfigurationIsVisible = 0; 437 | defaultConfigurationName = Release; 438 | }; 439 | /* End XCConfigurationList section */ 440 | }; 441 | rootObject = A410A96E1A2DB14B007C260E /* Project object */; 442 | } 443 | -------------------------------------------------------------------------------- /LCS/LCS/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // LCS 4 | // 5 | // Created by 杨萧玉 on 14/12/2. 6 | // Copyright (c) 2014年 杨萧玉. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | 11 | @NSApplicationMain 12 | class AppDelegate: NSObject, NSApplicationDelegate { 13 | 14 | 15 | 16 | func applicationDidFinishLaunching(_ aNotification: Notification) { 17 | // Insert code here to initialize your application 18 | } 19 | 20 | func applicationWillTerminate(_ aNotification: Notification) { 21 | // Insert code here to tear down your application 22 | } 23 | 24 | 25 | } 26 | 27 | -------------------------------------------------------------------------------- /LCS/LCS/Background.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Background.swift 3 | // LCS 4 | // 5 | // Created by 杨萧玉 on 14/12/2. 6 | // Copyright (c) 2014年 杨萧玉. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | 11 | class Background: NSView,NSTextFieldDelegate,NSMatrixDelegate { 12 | 13 | @IBOutlet weak var sequenceA: NSTextField! 14 | 15 | @IBOutlet weak var sequenceB: NSTextField! 16 | 17 | @IBOutlet weak var result: NSTextField! 18 | 19 | @IBOutlet weak var timeCost:NSTextField! 20 | 21 | var mode:Int = 0{ 22 | didSet{ 23 | run(); 24 | } 25 | } 26 | var lcs = LCS() 27 | var beginTime = Date(timeIntervalSince1970: 0) 28 | var endTime = Date(timeIntervalSince1970: 0) 29 | var costTime:TimeInterval { 30 | get{ 31 | return endTime.timeIntervalSince(beginTime)*1000 32 | } 33 | } 34 | override func draw(_ dirtyRect: NSRect) { 35 | super.draw(dirtyRect) 36 | 37 | // Drawing code here. 38 | } 39 | 40 | override func controlTextDidChange(_ obj: Notification) { 41 | run(); 42 | } 43 | 44 | func run(){ 45 | beginTime = Date(); 46 | switch mode{ 47 | case 0: 48 | result.stringValue = lcs.simpleLCS(sequenceA.stringValue, y: sequenceB.stringValue) 49 | case 1: 50 | result.stringValue = lcs.calculateLCS(sequenceA.stringValue, y: sequenceB.stringValue) 51 | default: 52 | result.stringValue = lcs.simpleLCS(sequenceA.stringValue, y: sequenceB.stringValue) 53 | } 54 | endTime = Date(); 55 | timeCost.stringValue = costTime.description 56 | } 57 | @IBAction func radioButtonclicked(_ sender:NSMatrix){ 58 | switch (sender.selectedCell() as! NSButtonCell).title { 59 | case "分治技术": 60 | mode = 0 61 | case "动态规划": 62 | mode = 1 63 | default: 64 | mode = 0 65 | } 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /LCS/LCS/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "mac", 5 | "size" : "16x16", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "mac", 10 | "size" : "16x16", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "mac", 15 | "size" : "32x32", 16 | "scale" : "1x" 17 | }, 18 | { 19 | "idiom" : "mac", 20 | "size" : "32x32", 21 | "scale" : "2x" 22 | }, 23 | { 24 | "idiom" : "mac", 25 | "size" : "128x128", 26 | "scale" : "1x" 27 | }, 28 | { 29 | "idiom" : "mac", 30 | "size" : "128x128", 31 | "scale" : "2x" 32 | }, 33 | { 34 | "idiom" : "mac", 35 | "size" : "256x256", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "mac", 40 | "size" : "256x256", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "mac", 45 | "size" : "512x512", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "mac", 50 | "size" : "512x512", 51 | "scale" : "2x" 52 | } 53 | ], 54 | "info" : { 55 | "version" : 1, 56 | "author" : "xcode" 57 | } 58 | } -------------------------------------------------------------------------------- /LCS/LCS/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSMinimumSystemVersion 26 | $(MACOSX_DEPLOYMENT_TARGET) 27 | NSHumanReadableCopyright 28 | Copyright © 2014年 杨萧玉. All rights reserved. 29 | NSMainStoryboardFile 30 | Main 31 | NSPrincipalClass 32 | NSApplication 33 | 34 | 35 | -------------------------------------------------------------------------------- /LCS/LCS/LCS.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LCS.swift 3 | // LCS 4 | // 5 | // Created by 杨萧玉 on 14/12/2. 6 | // Copyright (c) 2014年 杨萧玉. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | 11 | 12 | class LCS: NSObject { 13 | var C = [[Int]]() 14 | var B = [[Int]]() 15 | var result:String = "" 16 | 17 | func calculateLCS(_ x:String,y:String) -> String{ 18 | result = "" 19 | let m = x.characters.count 20 | let n = y.characters.count 21 | C = [[Int]](repeating: [Int](repeating: 0,count: n+1),count: m+1) 22 | B = [[Int]](repeating: [Int](repeating: 0,count: n+1),count: m+1) 23 | for (i,charx) in x.characters.enumerated() { 24 | for (j,chary) in y.characters.enumerated() { 25 | if charx==chary { 26 | C[i+1][j+1] = C[i][j] + 1 27 | B[i+1][j+1] = 1 28 | } 29 | else if C[i][j+1]>=C[i+1][j]{ 30 | C[i+1][j+1] = C[i][j+1] 31 | B[i+1][j+1] = 2 32 | } 33 | else { 34 | C[i+1][j+1] = C[i+1][j] 35 | B[i+1][j+1] = 3 36 | } 37 | } 38 | } 39 | var chars = [Character]() 40 | for char in x.characters { 41 | chars.append(char) 42 | } 43 | 44 | printLCS(chars, i: m, j: n) 45 | return result 46 | } 47 | 48 | fileprivate func printLCS(_ x:[Character],i:Int,j:Int) { 49 | if i==0||j==0 { 50 | return 51 | } 52 | if B[i][j]==1 { 53 | printLCS(x, i: i-1, j: j-1) 54 | // let range = Range(start: i, end: i) 55 | result.append(x[i-1]) 56 | } 57 | else if B[i][j]==2 { 58 | printLCS(x, i: i-1, j: j) 59 | } 60 | else { 61 | printLCS(x, i: i, j: j-1) 62 | } 63 | } 64 | 65 | func simpleLCS(_ x:String,y:String)->String{ 66 | let m = x.characters.count 67 | let n = y.characters.count 68 | if m==0||n==0 { 69 | return "" 70 | } 71 | var charsX = [Character]() 72 | var charsY = [Character]() 73 | for char in x.characters { 74 | charsX.append(char) 75 | } 76 | for char in y.characters { 77 | charsY.append(char) 78 | } 79 | if charsX[m-1]==charsY[n-1] { 80 | var result = simpleLCS(x.substring(to: x.characters.index(before: x.endIndex)), y: y.substring(to: y.characters.index(before: y.endIndex))) 81 | result.append(charsX[m-1]) 82 | return result 83 | } 84 | else { 85 | let z1 = simpleLCS(x.substring(to: x.characters.index(before: x.endIndex)), y: y) 86 | let z2 = simpleLCS(x, y: y.substring(to: y.characters.index(before: y.endIndex))) 87 | return z1.characters.count > z2.characters.count ? z1 : z2 88 | } 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /LCS/LCS/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // LCS 4 | // 5 | // Created by 杨萧玉 on 14/12/2. 6 | // Copyright (c) 2014年 杨萧玉. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | 11 | class ViewController: NSViewController { 12 | 13 | override func viewDidLoad() { 14 | super.viewDidLoad() 15 | // Do any additional setup after loading the view. 16 | } 17 | 18 | override var representedObject: Any? { 19 | didSet { 20 | // Update the view, if already loaded. 21 | } 22 | } 23 | 24 | 25 | } 26 | 27 | -------------------------------------------------------------------------------- /LCS/LCSTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /LCS/LCSTests/LCSTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LCSTests.swift 3 | // LCSTests 4 | // 5 | // Created by 杨萧玉 on 14/12/2. 6 | // Copyright (c) 2014年 杨萧玉. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | import XCTest 11 | 12 | class LCSTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testExample() { 25 | // This is an example of a functional test case. 26 | XCTAssert(true, "Pass") 27 | } 28 | 29 | func testPerformanceExample() { 30 | // This is an example of a performance test case. 31 | self.measure() { 32 | // Put the code you want to measure the time of here. 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /N-Queen/N-Queen.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | A4594BFC1A4933790084BBCE /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A4594BFB1A4933790084BBCE /* main.cpp */; }; 11 | /* End PBXBuildFile section */ 12 | 13 | /* Begin PBXCopyFilesBuildPhase section */ 14 | A4594BF61A4933790084BBCE /* CopyFiles */ = { 15 | isa = PBXCopyFilesBuildPhase; 16 | buildActionMask = 2147483647; 17 | dstPath = /usr/share/man/man1/; 18 | dstSubfolderSpec = 0; 19 | files = ( 20 | ); 21 | runOnlyForDeploymentPostprocessing = 1; 22 | }; 23 | /* End PBXCopyFilesBuildPhase section */ 24 | 25 | /* Begin PBXFileReference section */ 26 | A4594BF81A4933790084BBCE /* N-Queen */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "N-Queen"; sourceTree = BUILT_PRODUCTS_DIR; }; 27 | A4594BFB1A4933790084BBCE /* main.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = ""; }; 28 | /* End PBXFileReference section */ 29 | 30 | /* Begin PBXFrameworksBuildPhase section */ 31 | A4594BF51A4933790084BBCE /* Frameworks */ = { 32 | isa = PBXFrameworksBuildPhase; 33 | buildActionMask = 2147483647; 34 | files = ( 35 | ); 36 | runOnlyForDeploymentPostprocessing = 0; 37 | }; 38 | /* End PBXFrameworksBuildPhase section */ 39 | 40 | /* Begin PBXGroup section */ 41 | A4594BEF1A4933790084BBCE = { 42 | isa = PBXGroup; 43 | children = ( 44 | A4594BFA1A4933790084BBCE /* N-Queen */, 45 | A4594BF91A4933790084BBCE /* Products */, 46 | ); 47 | sourceTree = ""; 48 | }; 49 | A4594BF91A4933790084BBCE /* Products */ = { 50 | isa = PBXGroup; 51 | children = ( 52 | A4594BF81A4933790084BBCE /* N-Queen */, 53 | ); 54 | name = Products; 55 | sourceTree = ""; 56 | }; 57 | A4594BFA1A4933790084BBCE /* N-Queen */ = { 58 | isa = PBXGroup; 59 | children = ( 60 | A4594BFB1A4933790084BBCE /* main.cpp */, 61 | ); 62 | path = "N-Queen"; 63 | sourceTree = ""; 64 | }; 65 | /* End PBXGroup section */ 66 | 67 | /* Begin PBXNativeTarget section */ 68 | A4594BF71A4933790084BBCE /* N-Queen */ = { 69 | isa = PBXNativeTarget; 70 | buildConfigurationList = A4594BFF1A4933790084BBCE /* Build configuration list for PBXNativeTarget "N-Queen" */; 71 | buildPhases = ( 72 | A4594BF41A4933790084BBCE /* Sources */, 73 | A4594BF51A4933790084BBCE /* Frameworks */, 74 | A4594BF61A4933790084BBCE /* CopyFiles */, 75 | ); 76 | buildRules = ( 77 | ); 78 | dependencies = ( 79 | ); 80 | name = "N-Queen"; 81 | productName = "N-Queen"; 82 | productReference = A4594BF81A4933790084BBCE /* N-Queen */; 83 | productType = "com.apple.product-type.tool"; 84 | }; 85 | /* End PBXNativeTarget section */ 86 | 87 | /* Begin PBXProject section */ 88 | A4594BF01A4933790084BBCE /* Project object */ = { 89 | isa = PBXProject; 90 | attributes = { 91 | LastUpgradeCheck = 0700; 92 | ORGANIZATIONNAME = "杨萧玉"; 93 | TargetAttributes = { 94 | A4594BF71A4933790084BBCE = { 95 | CreatedOnToolsVersion = 6.1.1; 96 | }; 97 | }; 98 | }; 99 | buildConfigurationList = A4594BF31A4933790084BBCE /* Build configuration list for PBXProject "N-Queen" */; 100 | compatibilityVersion = "Xcode 3.2"; 101 | developmentRegion = English; 102 | hasScannedForEncodings = 0; 103 | knownRegions = ( 104 | en, 105 | ); 106 | mainGroup = A4594BEF1A4933790084BBCE; 107 | productRefGroup = A4594BF91A4933790084BBCE /* Products */; 108 | projectDirPath = ""; 109 | projectRoot = ""; 110 | targets = ( 111 | A4594BF71A4933790084BBCE /* N-Queen */, 112 | ); 113 | }; 114 | /* End PBXProject section */ 115 | 116 | /* Begin PBXSourcesBuildPhase section */ 117 | A4594BF41A4933790084BBCE /* Sources */ = { 118 | isa = PBXSourcesBuildPhase; 119 | buildActionMask = 2147483647; 120 | files = ( 121 | A4594BFC1A4933790084BBCE /* main.cpp in Sources */, 122 | ); 123 | runOnlyForDeploymentPostprocessing = 0; 124 | }; 125 | /* End PBXSourcesBuildPhase section */ 126 | 127 | /* Begin XCBuildConfiguration section */ 128 | A4594BFD1A4933790084BBCE /* Debug */ = { 129 | isa = XCBuildConfiguration; 130 | buildSettings = { 131 | ALWAYS_SEARCH_USER_PATHS = NO; 132 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 133 | CLANG_CXX_LIBRARY = "libc++"; 134 | CLANG_ENABLE_MODULES = YES; 135 | CLANG_ENABLE_OBJC_ARC = YES; 136 | CLANG_WARN_BOOL_CONVERSION = YES; 137 | CLANG_WARN_CONSTANT_CONVERSION = YES; 138 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 139 | CLANG_WARN_EMPTY_BODY = YES; 140 | CLANG_WARN_ENUM_CONVERSION = YES; 141 | CLANG_WARN_INT_CONVERSION = YES; 142 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 143 | CLANG_WARN_UNREACHABLE_CODE = YES; 144 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 145 | COPY_PHASE_STRIP = NO; 146 | ENABLE_STRICT_OBJC_MSGSEND = YES; 147 | ENABLE_TESTABILITY = YES; 148 | GCC_C_LANGUAGE_STANDARD = gnu99; 149 | GCC_DYNAMIC_NO_PIC = NO; 150 | GCC_OPTIMIZATION_LEVEL = 0; 151 | GCC_PREPROCESSOR_DEFINITIONS = ( 152 | "DEBUG=1", 153 | "$(inherited)", 154 | ); 155 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 156 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 157 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 158 | GCC_WARN_UNDECLARED_SELECTOR = YES; 159 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 160 | GCC_WARN_UNUSED_FUNCTION = YES; 161 | GCC_WARN_UNUSED_VARIABLE = YES; 162 | MACOSX_DEPLOYMENT_TARGET = 10.10; 163 | MTL_ENABLE_DEBUG_INFO = YES; 164 | ONLY_ACTIVE_ARCH = YES; 165 | SDKROOT = macosx; 166 | }; 167 | name = Debug; 168 | }; 169 | A4594BFE1A4933790084BBCE /* Release */ = { 170 | isa = XCBuildConfiguration; 171 | buildSettings = { 172 | ALWAYS_SEARCH_USER_PATHS = NO; 173 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 174 | CLANG_CXX_LIBRARY = "libc++"; 175 | CLANG_ENABLE_MODULES = YES; 176 | CLANG_ENABLE_OBJC_ARC = YES; 177 | CLANG_WARN_BOOL_CONVERSION = YES; 178 | CLANG_WARN_CONSTANT_CONVERSION = YES; 179 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 180 | CLANG_WARN_EMPTY_BODY = YES; 181 | CLANG_WARN_ENUM_CONVERSION = YES; 182 | CLANG_WARN_INT_CONVERSION = YES; 183 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 184 | CLANG_WARN_UNREACHABLE_CODE = YES; 185 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 186 | COPY_PHASE_STRIP = YES; 187 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 188 | ENABLE_NS_ASSERTIONS = NO; 189 | ENABLE_STRICT_OBJC_MSGSEND = YES; 190 | GCC_C_LANGUAGE_STANDARD = gnu99; 191 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 192 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 193 | GCC_WARN_UNDECLARED_SELECTOR = YES; 194 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 195 | GCC_WARN_UNUSED_FUNCTION = YES; 196 | GCC_WARN_UNUSED_VARIABLE = YES; 197 | MACOSX_DEPLOYMENT_TARGET = 10.10; 198 | MTL_ENABLE_DEBUG_INFO = NO; 199 | SDKROOT = macosx; 200 | }; 201 | name = Release; 202 | }; 203 | A4594C001A4933790084BBCE /* Debug */ = { 204 | isa = XCBuildConfiguration; 205 | buildSettings = { 206 | PRODUCT_NAME = "$(TARGET_NAME)"; 207 | }; 208 | name = Debug; 209 | }; 210 | A4594C011A4933790084BBCE /* Release */ = { 211 | isa = XCBuildConfiguration; 212 | buildSettings = { 213 | PRODUCT_NAME = "$(TARGET_NAME)"; 214 | }; 215 | name = Release; 216 | }; 217 | /* End XCBuildConfiguration section */ 218 | 219 | /* Begin XCConfigurationList section */ 220 | A4594BF31A4933790084BBCE /* Build configuration list for PBXProject "N-Queen" */ = { 221 | isa = XCConfigurationList; 222 | buildConfigurations = ( 223 | A4594BFD1A4933790084BBCE /* Debug */, 224 | A4594BFE1A4933790084BBCE /* Release */, 225 | ); 226 | defaultConfigurationIsVisible = 0; 227 | defaultConfigurationName = Release; 228 | }; 229 | A4594BFF1A4933790084BBCE /* Build configuration list for PBXNativeTarget "N-Queen" */ = { 230 | isa = XCConfigurationList; 231 | buildConfigurations = ( 232 | A4594C001A4933790084BBCE /* Debug */, 233 | A4594C011A4933790084BBCE /* Release */, 234 | ); 235 | defaultConfigurationIsVisible = 0; 236 | defaultConfigurationName = Release; 237 | }; 238 | /* End XCConfigurationList section */ 239 | }; 240 | rootObject = A4594BF01A4933790084BBCE /* Project object */; 241 | } 242 | -------------------------------------------------------------------------------- /N-Queen/N-Queen.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /N-Queen/N-Queen/main.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // main.cpp 3 | // N-Queen 4 | // 5 | // Created by 杨萧玉 on 14/12/23. 6 | // Copyright (c) 2014年 杨萧玉. All rights reserved. 7 | // 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | using namespace std; 27 | #define random(x) (rand()%x) 28 | class Solution { 29 | public: 30 | set> stack; 31 | vector> result; 32 | int size=0; 33 | vector> solveNQueens(int n) { 34 | size=n; 35 | backtrack(0); 36 | return result; 37 | } 38 | void backtrack(int i){ 39 | if (i==size) { 40 | generateResult(); 41 | return; 42 | } 43 | for (int j=0; j(i,j)); 46 | backtrack(i+1); 47 | stack.erase(pair(i,j)); 48 | } 49 | } 50 | } 51 | void generateResult(){ 52 | vector temp(size,string(size,'_')); 53 | set>::iterator iter = stack.begin(); 54 | for (; iter!=stack.end(); iter++) { 55 | temp[iter->first].replace(iter->second, 1, "Q"); 56 | } 57 | result.push_back(temp); 58 | } 59 | bool check(int i,int j){ 60 | set>::iterator iter = stack.begin(); 61 | for (; iter!=stack.end(); iter++) { 62 | if (iter->first==i||iter->second==j||(abs(iter->first-i)==abs(iter->second-j))) { 63 | return false; 64 | } 65 | } 66 | return true; 67 | } 68 | vector> randomQueen(int n){ 69 | vector> result; 70 | for (int i=0; i(i,random(n))); 72 | } 73 | return result; 74 | } 75 | vector> checkRandomRes(int n){ 76 | size=n; 77 | bool success=false; 78 | while (!success) { 79 | vector> input=randomQueen(n); 80 | auto i=input.begin(); 81 | stack.clear(); 82 | bool shutdown=false; 83 | for (; i!=input.end()&&!shutdown; i++) { 84 | if (check(i->first, i->second)) { 85 | stack.insert(*i); 86 | } 87 | else{ 88 | shutdown=true; 89 | } 90 | } 91 | if (!shutdown) { 92 | success=true; 93 | } 94 | } 95 | generateResult(); 96 | return result; 97 | } 98 | }; 99 | 100 | int main(int argc, const char * argv[]) { 101 | // insert code here... 102 | Solution s=Solution(); 103 | vector> result=s.solveNQueens(12);//随机回溯求解N皇后 104 | // vector> result=s.checkRandomRes(12);//随机算法求解N皇后 105 | auto i=result.begin(); 106 | while (i!=result.end()) { 107 | auto j=(*i).begin(); 108 | while (j!=(*i).end()) { 109 | cout<<*j<