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 | |
| extension Array { | |
| mutating func randomize() { | |
| for i in 0..<self.count { | |
| let r = Int.random(in: 0..<Int(self.count - i)) | |
| (self[i], self[i+r]) = (self[i+r], self[i]) | |
| } | |
| } | |
| } |
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 User : Codable { | |
| let firstName: String | |
| let lastName: String | |
| let id: Int | |
| } | |
| let users = [User(firstName: "John", lastName: "Doe", id: 1), | |
| User(firstName: "Jane", lastName: "Doe", id: 2)] |
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
| struct SampleStruct | |
| { | |
| 1: i32 key | |
| 2: string value | |
| } | |
| service TestService | |
| { | |
| string Hello(1:string HelloString), | |
| SampleStruct GetSampleStruct(1: i32 key, 2:string value), |
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 Thrift | |
| do { | |
| let serviceURL: URL = URL(string: "http://localhost:9090")! | |
| let session: URLSession = URLSession(configuration: .default) | |
| let transport: THTTPSessionTransport = THTTPSessionTransport.Factory(session: session, url: serviceURL).newTransport() | |
| let proto = TBinaryProtocol(on: transport) | |
| let client = TestServiceClient(inoutProtocol: proto) |
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 Thrift | |
| import ThriftSwiftNio | |
| class TestServiceHandler : TestService { | |
| func Hello(HelloString: String) throws -> String { | |
| return "Hello " + HelloString | |
| } | |
| func GetSampleStruct(key: Int32, value: String) throws -> SampleStruct { |
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 final class SampleStruct { | |
| public var key: Int32 | |
| public var value: String | |
| } | |
| public protocol TestService { | |
| func Hello(HelloString: String) throws -> String | |
| func GetSampleStruct(key: Int32, value: String) throws -> SampleStruct | |
| } |
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
| #include <list> | |
| int main(int argc, const char * argv[]) { | |
| std::list<void*> list; | |
| list.push_back((void*)"1"); | |
| list.push_back((void*)"2"); | |
| list.push_back((void*)"3"); | |
| list.push_front((void*)"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
| let list = SwiftListWrapper(dataSize: 1) | |
| list.push_back(value: "1".data(using: .utf8)!) | |
| list.push_back(value: "2".data(using: .utf8)!) | |
| list.push_back(value: "3".data(using: .utf8)!) | |
| list.push_front(value: "0".data(using: .utf8)!) | |
| XCTAssertEqual(list.size(), 4) | |
| XCTAssertEqual(String.init(data: list.front()!, encoding: .utf8), "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 | |
| import TensorFlow | |
| import numsw | |
| var tf = TensorFlow() | |
| let a = tf.constant(NDArray<Float>(shape: [3], elements: [5, 7, 10])) | |
| let b = tf.constant(NDArray<Float>(shape: [3], elements: [2, 3, 21])) | |
| let c = tf.constant(NDArray<Float>(shape: [3], elements: [3, 5, 7])) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.