This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // Singleton | |
| // | |
| // Created by SeaHub on 2017/3/2. | |
| // Copyright © 2017年 @Seahub All rights reserved. | |
| // | |
| #import <Foundation/Foundation.h> | |
| @interface Singleton : NSObject <NSCopying, NSMutableCopying> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // QuickSort | |
| // | |
| // Created by SeaHub on 2017/3/3. | |
| // Copyright © 2017年 @Seahub. All rights reserved. | |
| // | |
| #include <iostream> | |
| #include <vector> | |
| using namespace std; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #define AADD(c, o) GSDebugAllocationAdd(c, o) | |
| static SEL cxx_construct, cxx_destruct; | |
| /** | |
| * Calls the C++ constructors for this object, starting with the ones declared | |
| * in aClass. The compiler generates two methods on Objective-C++ classes that | |
| * static instances of C++ classes as ivars. These are -.cxx_construct and | |
| * -.cxx_destruct. The -.cxx_construct methods must be called in order from | |
| * the root class to all subclasses, to ensure that subclass ivars are | |
| * initialised after superclass ones. This must be done in reverse for |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Increments the reference count and returns the receiver.<br /> | |
| * The default implementation does this by calling NSIncrementExtraRefCount() | |
| */ | |
| - (id)retain { | |
| #if (GS_WITH_GC == 0) | |
| NSIncrementExtraRefCount(self); | |
| #endif | |
| return self; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Decrements the retain count for the receiver if greater than zero, | |
| * otherwise calls the dealloc method instead.<br /> | |
| * The default implementation calls the NSDecrementExtraRefCountWasZero() | |
| * function to test the extra reference count for the receiver (and | |
| * decrement it if non-zero) - if the extra reference count is zero then | |
| * the retain count is one, and the dealloc method is called.<br /> | |
| * In GNUstep, the [NSObject+enableDoubleReleaseCheck:] method may be used | |
| * to turn on checking for ratain/release errors in this method. | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Deallocates the receiver by calling NSDeallocateObject() with self | |
| * as the argument.<br /> | |
| * <p> | |
| * You should normally call the superclass implementation of this method | |
| * when you override it in a subclass, or the memory occupied by your | |
| * object will not be released. | |
| * </p> | |
| * <p> | |
| * <code>NSObject</code>'s implementation of this method |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // BinarySearch | |
| // | |
| // Created by SeaHub on 2017/3/4. | |
| // Copyright © 2017年 @Seahub. All rights reserved. | |
| // | |
| #include <iostream> | |
| #include <vector> | |
| using namespace std; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // HeapSort | |
| // | |
| // Created by SeaHub on 2017/3/11. | |
| // Copyright © 2017年 @Seahub. All rights reserved. | |
| // | |
| #include <vector> | |
| #include <iostream> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 有一棵二叉树,请设计一个算法,按照层次打印这棵二叉树。 | |
| // 给定二叉树的根结点root,请返回打印结果,结果按照每一层一个数组进行储存, | |
| // 所有数组的顺序按照层数从上往下,且每一层的数组内元素按照从左往右排列。保证结点数小于等于500。 | |
| struct TreeNode { | |
| int val; | |
| struct TreeNode *left; | |
| struct TreeNode *right; | |
| TreeNode(int x) : | |
| val(x), left(NULL), right(NULL) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 如果对于一个字符串A,将A的前面任意一部分挪到后边去形成的字符串称为A的旋转词。 | |
| // 比如A="12345",A的旋转词有"12345","23451","34512","45123"和"51234"。 | |
| // 对于两个字符串A和B,请判断A和B是否互为旋转词。 | |
| // 给定两个字符串A和B及他们的长度lena,lenb,请返回一个bool值,代表他们是否互为旋转词。 | |
| class Rotation { | |
| public: | |
| bool chkRotation(string A, int lena, string B, int lenb) { | |
| if (lena != lenb) { | |
| return false; |
OlderNewer