How to use the sorted-array-functions.remove function in sorted-array-functions

To help you get started, we’ve selected a few sorted-array-functions examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github davidmarkclements / proffer / lib / core-events / code-move.js View on Github external
const entry = state.code[state.addresses[index]]
    const edge = to + entry[SIZE]

    sorted.remove(state.addresses, from)
    state.code[from] = undefined

    // clear out entries in what will be the new address range of the moved entry
    var addr = edge - 1
    while (addr >= to) {
      const ix = sorted.lte(state.addresses, addr)
      if (ix === -1) break
      const match = state.addresses[ix]
      addr = match - 1
      // code previously cleared:
      if (state.code[match] === undefined) {
        sorted.remove(state.addresses, match)
        continue
      }
      if (match + +state.code[match][SIZE] <= to) continue

      sorted.remove(state.addresses, match)
      state.code[match] = undefined
    }

    entry[START] = toAddr
    state.code[to] = entry
    sorted.add(state.addresses, to)

    cb()
  }
}
github davidmarkclements / proffer / lib / core-events / code-move.js View on Github external
return function (row, cb) {
    const [event, fromAddr, toAddr] = row
    const from = parseInt(fromAddr, 16)
    const to = parseInt(toAddr, 16)

    const index = sorted.lte(state.addresses, from)
    if (index === -1) {
      opts.warn(`${event} address ${fromAddr} not found`)
      cb()
      return
    }
    const entry = state.code[state.addresses[index]]
    const edge = to + entry[SIZE]

    sorted.remove(state.addresses, from)
    state.code[from] = undefined

    // clear out entries in what will be the new address range of the moved entry
    var addr = edge - 1
    while (addr >= to) {
      const ix = sorted.lte(state.addresses, addr)
      if (ix === -1) break
      const match = state.addresses[ix]
      addr = match - 1
      // code previously cleared:
      if (state.code[match] === undefined) {
        sorted.remove(state.addresses, match)
        continue
      }
      if (match + +state.code[match][SIZE] <= to) continue
github davidmarkclements / proffer / lib / core-events / code-delete.js View on Github external
return function (row, cb) {
    const [event, start] = row
    const addr = parseInt(start, 16)
    const success = sorted.remove(state.addresses, addr)
    if (success === true) {
      state.code[addr] = undefined
      cb()
    } else {
      state.opts.warn(`${event} address ${start} not found`)
      cb()
    }
  }
}
github juliangruber / bisect-sorted-set / index.js View on Github external
Set.prototype.del = function (idx) {
  var entry = new Entry(idx, null)
  sorted.remove(this._list, entry, cmp)
}

sorted-array-functions

Maintain and search through a sorted array using some low level functions

MIT
Latest version published 4 years ago

Package Health Score

65 / 100
Full package analysis

Similar packages