Skip to content

Instantly share code, notes, and snippets.

View artem-shmatkov's full-sized avatar
🏠
Working from home

Art Shmatkov artem-shmatkov

🏠
Working from home
View GitHub Profile
@artem-shmatkov
artem-shmatkov / COW-Impl.swift
Last active March 27, 2021 08:22 — forked from LucianoPAlmeida/COW-Impl.swift
Swift example of How to implement COW for custom value types.
final class Ref<T> {
var val : T
init(_ v : T) {val = v}
}
struct Box<T> {
var ref : Ref<T>
init(_ x : T) { ref = Ref(x) }
var value: T {
@artem-shmatkov
artem-shmatkov / COW.swift
Created March 27, 2021 07:55 — forked from LucianoPAlmeida/COW.swift
Copy-on-Write
import Foundation
func print(address o: UnsafeRawPointer ) {
print(String(format: "%p", Int(bitPattern: o)))
}
var array1: [Int] = [0, 1, 2, 3]
var array2 = array1
//Print with just assign