RVS_SequenceProtocol
public protocol RVS_SequenceProtocol : Sequence
If you conform to this protocol, you get a few basic Sequence attributes for free.
You’ll need to set up a sequence_contents Array (read/write), and set the Element type, and that’s about all.
This also gives you a read-only subscript.
This cannot be applied to enums, as it requires a stored property.
-
subscript(_:)
Default implementationSubscript access is get-only (for safety).
Default Implementation
Returns an indexed element.
Declaration
Swift
subscript(inIndex: Int) -> Element { get }
Parameters
index
The 0-based index to subscript. Must be less than count.
-
Declaration
Swift
init(sequence_contents: [Element])
Parameters
sequence_contents
An Array of the element type, to initialize the value.
-
removeAll()
Default implementationThis allows us to remove all the elements in the sequence. It is a mutating function/method.
Default Implementation
Default implementation should do fine for us.
Declaration
Swift
mutating func removeAll()