def --()

in algebird-core/src/main/scala/com/twitter/algebird/immutable/BitSet.scala [703:755]


    def --(rhs: BitSet): BitSet =
      rhs match {
        case _ if this eq rhs =>
          Empty
        case b @ Branch(_, _, _) if height < b.height =>
          if (offset < b.offset || b.limit <= offset) this
          else {
            val c = b.children(b.index(offset))
            if (c == null) this else this -- c
          }
        case b @ Branch(_, _, _) if height == b.height =>
          if (offset != b.offset) {
            this
          } else {
            var newChildren: Array[BitSet] = null
            var i = 0
            while (i < 32) {
              val c0 = children(i)
              val c1 = b.children(i)
              val cc = if (c0 == null || c1 == null) c0 else c0 -- c1
              if (!(c0 eq cc)) {
                if (newChildren == null) {
                  newChildren = new Array[BitSet](32)
                  var j = 0
                  while (j < i) {
                    newChildren(j) = children(j)
                    j += 1
                  }
                }
                newChildren(i) = cc
              } else if (newChildren != null) {
                newChildren(i) = c0
              }
              i += 1
            }
            if (newChildren == null) this
            else Branch(offset, height, newChildren)
          }
        case _ /* height > rhs.height */ =>
          if (rhs.offset < offset || limit <= rhs.offset) {
            this
          } else {
            // this branch contains rhs, so find its index
            val i = index(rhs.offset)
            val c = children(i)
            if (c == null) {
              this
            } else {
              val cc = c -- rhs
              if (c eq cc) this else replace(i, cc)
            }
          }
      }