mutating func add()

in Packages/ClientRuntime/Sources/Middleware/OrderedGroup.swift [7:24]


    mutating func add(position: Position, ids: String...) {
        if ids.isEmpty { return}
        var unDuplicatedList = ids
        for index in  0...(ids.count - 1) {
            let id = ids[index]
            if order.contains(id) {
                // if order already has the id, remove it from the list so it is not re-inserted
                unDuplicatedList.remove(at: index)
            }
        }
        
        switch position {
        case .after:
            order.append(contentsOf: unDuplicatedList)
        case .before:
            order.insert(contentsOf: unDuplicatedList, at: 0)
        }
    }