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 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
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
#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 <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
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 | |
class Stack<T> { | |
private typealias Node = StackNode<T> | |
private var _top : Node? | |
private var _size : UInt = 0 | |
//MARK: Public API | |
internal func empty() -> Bool { |
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 LinkedList<T : Equatable> { | |
private typealias Node = LinkedListNode<T> | |
private var _head : Node? | |
private var _tail : Node? | |
private var _size : UInt = 0 | |
//MARK : Public API | |
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 Queue<T> { | |
private typealias Node = QueueNode<T> | |
private var _top : Node? | |
private var _last : Node? | |
private var _size : UInt = 0 | |
//MARK : Public API |
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
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { | |
if (range.location == textField.text.length && [string isEqualToString:@" "]) { | |
textField.text = [textField.text stringByAppendingString:@"\u00a0"]; | |
return NO; | |
} | |
return YES; | |
} |