https://github.com/regexident/interner
Swift implementation of general-purpose interners for every use case
https://github.com/regexident/interner
flyweight-pattern interning string-interning
Last synced: 3 months ago
JSON representation
Swift implementation of general-purpose interners for every use case
- Host: GitHub
- URL: https://github.com/regexident/interner
- Owner: regexident
- License: mpl-2.0
- Created: 2020-04-14T13:01:05.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2021-02-10T14:06:53.000Z (over 4 years ago)
- Last Synced: 2025-01-19T01:02:33.396Z (5 months ago)
- Topics: flyweight-pattern, interning, string-interning
- Language: Swift
- Size: 42 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Interner
Fast general-purpose interners for every use case
Interners take complex values and map them to [trivially-comparable stand-ins](https://en.wikipedia.org/wiki/Flyweight_pattern) that can later be resolved back to their source values.
Interners are often found in software like parsers, language interpreters, and compilers; they can be used whenever a given algorithm compares its inputs by identity only.## Examples
```swift
import Internerlet interner = Interner()
let string = "Hello"
let symbol = interner.interned(string)
let resolved = interner.lookup(symbol)XCTAssert(resolved == string)
```## License
This project is licensed under the [**MPL-2.0**](https://www.tldrlegal.com/l/mpl-2.0) – see the [LICENSE.md](LICENSE.md) file for details.