Archived
Initial commit; substitutions can be reviewed, no further functionality implemented yet
This commit is contained in:
+39
@@ -0,0 +1,39 @@
|
||||
//
|
||||
// SimpleDictionary.swift
|
||||
// SwiftSoup
|
||||
//
|
||||
// Created by Nabil Chatbi on 30/10/16.
|
||||
// Copyright © 2016 Nabil Chatbi.. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
public class SimpleDictionary<KeyType: Hashable, ValueType> {
|
||||
|
||||
public typealias DictionaryType = [KeyType: ValueType]
|
||||
public private(set) var values = DictionaryType()
|
||||
|
||||
public init() {
|
||||
}
|
||||
|
||||
public var count: Int {
|
||||
return values.count
|
||||
}
|
||||
|
||||
public func remove(_ key: KeyType) {
|
||||
values.removeValue(forKey: key)
|
||||
}
|
||||
|
||||
public func contains(_ key: KeyType) -> Bool {
|
||||
return self.values[key] != nil
|
||||
}
|
||||
|
||||
public func put(_ value: ValueType, forKey key: KeyType) {
|
||||
self.values[key] = value
|
||||
}
|
||||
|
||||
public func get(_ key: KeyType) -> ValueType? {
|
||||
return self.values[key]
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user