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 arr = (0...15).map {$0*2} | |
func binarySearch<T : Comparable>(arr : Array<T>, value : T) -> Bool { | |
let midPosition = arr.startIndex.advancedBy(arr.startIndex.distanceTo(arr.endIndex)/2) | |
let midElement = arr[midPosition] | |
guard midElement != value else { | |
return true | |
} |
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> | |
@interface NSObject (AssociatedObjects) | |
- (void)associatedValue:(id)value withKey:(void *)key; | |
- (id)associatedValueForKey:(void *)key; | |
@en |
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 <stdio.h> | |
#include <stdlib.h> | |
#include <math.h> | |
#define K 9000000000 | |
typedef struct { | |
double i; | |
double j; | |
} pair; |
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 java.util.ArrayList; | |
import java.util.Random; | |
class Team { | |
private String name; | |
public Team(String name) { | |
this.name = name; | |
} |
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 UserInformationHandler { | |
// MARK: - Public api | |
func retrieve() { | |
let data = request() | |
let user = parse(data: data) | |
store(user: user) | |
} | |
} |
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 UserInformationHandler { | |
// MARK: - Properties | |
let requester: UserInformationRequesteable | |
let parser: UserInformationParseable | |
let storer: UserInformationStoreable | |
// MARK - Life cycle | |
init(requester: UserInformationRequesteable, | |
parser: UserInformationParseable, |
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 Team { | |
var runners: [Runner] = ... | |
var riders: [Rider] = ... | |
func reset() { | |
runners.forEach{ $0.reset() } | |
riders.forEach { $0.reset() } | |
} | |
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 Team { | |
var runners: [Runner] = ... | |
var riders: [Rider] = ... | |
var swimmers: [Swimmer] = ... | |
func reset() { | |
runners.forEach{ $0.reset() } | |
riders.forEach { $0.reset() } | |
swimmers.forEach { $0.reset() } |
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 Team { | |
var athletes: [Athlete] = ... | |
func reset() { | |
athletes.forEach{ $0.reset() } | |
} | |
} |
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 ContentController { | |
func show() { | |
// Do stuff | |
} | |
} | |
class SubscriptorContentController: ContentController { |