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
import Foundation | |
enum ANSIColor: UInt8 { | |
enum Platte: String { | |
case WHITE_ALL = "\u{2588}" | |
case WHITE_BLACK = "\u{2580}" | |
case BLACK_WHITE = "\u{2584}" | |
case BLACK_ALL = "" | |
} |
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
const canvas = document.getElementById('canvas'), | |
context = canvas.getContext('2d'), | |
slidesSelect = document.getElementById('sideSelect'), | |
startAngleSelect = document.getElementById('startAngleSelect'), | |
fillCheckbox = document.getElementById('fillCheckbox'), | |
mosuseDown = {x:0, y: 0}, | |
rubberBandRect = {} |
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
import Foundation | |
import OpenCL | |
func contextCount() throws { | |
var platform: cl_platform_id? | |
guard clGetPlatformIDs(1, &platform, nil) >= 0 else { | |
fatalError("找不到任何平台") | |
} | |
var devices = [cl_device_id?]() |
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
#import <Foundation/Foundation.h> | |
/// Utilities for NSStrings containing HTML | |
@interface NSString (GTMNSStringHTMLAdditions) | |
/// Get a string where internal characters that need escaping for HTML are escaped | |
// | |
/// For example, '&' become '&'. This will only cover characters from table | |
/// A.2.2 of http://www.w3.org/TR/xhtml1/dtds.html#a_dtd_Special_characters | |
/// which is what you want for a unicode encoded webpage. If you have a ascii |
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
// | |
// Sort.swift | |
// CLSwift | |
// | |
// Created by modao on 2018/3/11. | |
// Copyright © 2018年 MockingBot. All rights reserved. | |
// | |
import Foundation |
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
class MBSlideInAnimationManager: NSObject { | |
var direction = PresentationDirection.left | |
var disableCompactHeight = false | |
enum PresentationDirection { | |
case left, top, right, bottom | |
} | |
} |
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
extension String { | |
subscript (i: Int) -> Character { | |
return self[index(startIndex, offsetBy: i)] | |
} | |
subscript (bounds: CountableRange<Int>) -> Substring { | |
let start = index(startIndex, offsetBy: bounds.lowerBound) | |
let end = index(startIndex, offsetBy: bounds.upperBound) | |
return self[start ..< end] | |
} | |
subscript (bounds: CountableClosedRange<Int>) -> Substring { |
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
public extension String { | |
func find(_ text: String) -> [Int] { | |
guard text.count <= self.count else {// 要查找的子串长度大于字符串长度,比较没有了意义…… | |
return [] | |
} | |
// 字符串子串前缀与后缀最大公共长度 | |
let getNext: (String) -> [Int] = { txt -> [Int] in | |
var arr = [Int](repeating: 0, count: txt.count+1) | |
//0和1的值肯定是0 | |
arr[0] = 0 |
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
import Foundation | |
struct AVLTree<T: Comparable> { | |
class AVLTreeNode<T: Comparable> { | |
typealias SearchResult = (isFound: Bool, searchNode: AVLTreeNode?, parent: AVLTreeNode?) | |
/// 节点携带的数据 | |
var data: T | |
/// 父节点 | |
var parentNode: AVLTreeNode? | |
/// 左节点 |
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
import Foundation | |
class HashableObject { | |
private static var hashTable = [Int: Int]() | |
private(set) var hashKey: Int = 0 | |
private(set) var id: Int = 0 | |
private(set) static var globalCount = 0 | |
private static var queue = DispatchQueue(label: "your.queue.identifier") |
OlderNewer