Singly linked list in Swift, but you get a value type instead. What a terrible idea.
public struct LinkedList<Element> {
private enum Node {
case value(Element)
indirect case node(value: Element, next: Node)
}
}
And this, of course, is not a new idea. It has been explored in posts like What are indirect enums? or Swift Algorithm Club: Swift Binary Search Tree Data Structure. But I only saw them after writing all the code ヽ( ̄~ ̄)ノ Anyways, good linked list practice, I guess.
- CustomDebugStringConvertible
- CustomReflectable
- CustomStringConvertible
-
CVarArgDeclaring conformance to the CVarArg protocol for types defined outside the standard library is not supported.
- Decodable when Element conforms to Decodable.
- Encodable when Element conforms to Encodable.
- Equatable when Element conforms to Equatable.
- ExpressibleByArrayLiteral
- Hashable when Element conforms to Hashable.
- MutableCollection
- Benchmark Sequence conformance performance
- Benchmark Collection conformance performance
- Benchmark MutableCollection conformance performance
- Implement some methods that usually requires BidirectionalCollection
- reversed
- ...
- RangeReplaceableCollection
- Benchmark, since default implementations are of real nightmare
- Try to be like Array
- Implement slices like ArraySlice?