Bag
public struct Bag<Element>
extension Bag: RandomAccessCollection
An unordered, non-unique collection of values of type Element
.
-
A uniquely identifying token for removing a value that was inserted into a Bag.
Declaration
Swift
public struct Token
-
Insert the given value into
self
, and return a token that can later be passed toremove(using:)
.Declaration
Swift
@discardableResult public mutating func insert(_ value: Element) -> Token
Parameters
value
A value that will be inserted.
-
Remove a value, given the token returned from
insert()
.Note
If the value has already been removed, nothing happens.
Declaration
Swift
@discardableResult public mutating func remove(using token: Token) -> Element?
Parameters
token
A token returned from a call to
insert()
. -
Declaration
Swift
public var startIndex: Int { get }
-
Declaration
Swift
public var endIndex: Int { get }
-
Declaration
Swift
public subscript(index: Int) -> Element { get }
-
Declaration
Swift
public func makeIterator() -> Iterator