Swiftpack.co - Package - pumperknickle/AwesomeDictionary

Awesome Dictionary

Awesome Dictionary is a pure Swift implementation of a Dictionary or an abstract data type composed of a collection of (key, value) pairs, such that each possible key appears at most once in the collection. Instead of using hash tables, it uses a radix trie, which is essentially a compressed trie.

Features

  1. Functional
  • All operations create new objects.
  • All mappings in AwesomeDictionary are immutable.
  1. Generic
  • Can be used with any Key type that conforms to BinaryEncodable.
  • Can be used with any Value type that conforms to Codable.
  1. Deterministic
  • Two dictionaries with the same key value pairs are guaranteed to be the same.
  • Two dictionaries with the same key value pairs are guaranteed to serialized the same byte for byte.
  1. Efficient
  • Modify existing dictionaries efficiently and functionally.
  1. Codable
  • Easily serializable to and from JSON and other encodings.

Installation

Swift Package Manager

Add AwesomeDictionary to Package.swift and the appropriate targets

dependencies: [
.package(url: "https://github.com/pumperknickle/AwesomeDictionary.git", from: "0.0.1")
]

Usage

Importing

Use AwesomeDictionary by including it in the imports of your swift file

import AwesomeDictionary

Initialization

Create an empty generic mapping

let newMapping = Mapping<String, [[String]]>()

Getting

Use subscript to get the value of a key.

let value = newMapping["foo"]

Setting

When setting, a new structure is returned with the new key value pair inserted.

let modifiedMap = newMapping.setting(key: "foo", value: [["fooValue"]])

Deleting

When deleting, a new structure is returned with the entry corresponding to the key deleted.

let modifiedMap = newMapping.deleting(key: "foo")

Github

link
Stars: 0

Used By

Total: 0

Releases

- 2020-02-21 17:38:41

- 2019-12-31 21:25:49

- 2019-12-10 17:38:03

- 2019-10-19 17:45:04

- 2019-10-19 13:16:09

- 2019-10-15 14:26:37