Skip to content

GcmDistributer

Manabu Tonosaki edited this page Jan 2, 2022 · 1 revision

Example

struct GcmNode : Hashable {
    var id: String = UUID().uuidString
    var name: String
    func hash(into hasher: inout Hasher) {
        hasher.combine(id)
    }
}

var gcm = GcmDistributer()
gcm.append(GcmNode(name: "A"), frequency: 6)
gcm.append(GcmNode(name: "B"), frequency: 3)
gcm.append(GcmNode(name: "C"), frequency: 1)

##OUTPUTS

for maybeNode in gcm {
    if let node = maybeNode as? GcmNode {
        print( node.name )
    }
}

A
B
A
C
A
B
A
A
B
A

Clone this wiki locally