Back
popTail (clj)
(source)interface
(popTail level node)
Examples
clojure/core.rrb-vector
(ns clojure.core.rrb-vector.transients
(:require [clojure.core.rrb-vector.parameters :as p]
[clojure.core.rrb-vector.nodes :refer [ranges last-range
overflow?]])
(:import (clojure.core.rrb_vector.nodes NodeManager)
(clojure.core ArrayManager)
(java.util.concurrent.atomic AtomicReference)))
(definterface ITransientHelper
(editableRoot [^clojure.core.rrb_vector.nodes.NodeManager nm
^clojure.core.ArrayManager am
root])
(editableTail [^clojure.core.ArrayManager am
tail])
(ensureEditable [^clojure.core.rrb_vector.nodes.NodeManager nm
root])
(ensureEditable [^clojure.core.rrb_vector.nodes.NodeManager nm
^clojure.core.ArrayManager am
^java.util.concurrent.atomic.AtomicReference root-edit
current-node
^int shift])
(pushTail [^clojure.core.rrb_vector.nodes.NodeManager nm
^clojure.core.ArrayManager am
^int shift
^int cnt
^java.util.concurrent.atomic.AtomicReference root-edit
current-node
tail-node])
(popTail [^clojure.core.rrb_vector.nodes.NodeManager nm
^clojure.core.ArrayManager am
^int shift
^int cnt
^java.util.concurrent.atomic.AtomicReference root-edit
current-node])
(doAssoc [^clojure.core.rrb_vector.nodes.NodeManager nm
^clojure.core.ArrayManager am
^int shift
^java.util.concurrent.atomic.AtomicReference root-edit
current-node
^int i
val])
(newPath [^clojure.core.rrb_vector.nodes.NodeManager nm
^clojure.core.ArrayManager am
tail
^java.util.concurrent.atomic.AtomicReference edit
^int shift
current-node]))
(popTail [this nm am shift cnt root-edit current-node]
(let [ret (.ensureEditable this nm am root-edit current-node shift)]
(if (.regular nm ret)
(let [subidx (bit-and
(bit-shift-right (unchecked-subtract-int cnt (int 2))
(int shift))
(int 0x1f))]
(cond
(> shift 5)
(let [child (.popTail this nm am
(unchecked-subtract-int shift 5)
cnt ;; TBD: Should this be smaller than cnt?
root-edit
(aget ^objects (.array nm ret) subidx))]
(if (and (nil? child) (zero? subidx))
nil
(let [arr (.array nm ret)]
(aset ^objects arr subidx child)
ret)))
:else
(let [arr (.array nm ret)]
(aset ^objects arr subidx nil)
ret)))
(let [rngs (ranges nm ret)
subidx (unchecked-dec-int (aget rngs 32))]
(cond
(> shift 5)
(let [child (aget ^objects (.array nm ret) subidx)
child-cnt (if (zero? subidx)
(aget rngs 0)
(unchecked-subtract-int
(aget rngs subidx)
(aget rngs (unchecked-dec-int subidx))))
new-child (.popTail this nm am
(unchecked-subtract-int shift 5)
child-cnt
root-edit
child)]
(cond
(and (nil? new-child) (zero? subidx))
nil
clojure/core.rrb-vector
(ns clojure.core.rrb-vector.transients
(:require [clojure.core.rrb-vector.parameters :as p]
[clojure.core.rrb-vector.nodes :refer [ranges last-range
overflow?]])
(:import (clojure.core.rrb_vector.nodes NodeManager)
(clojure.core ArrayManager)
(java.util.concurrent.atomic AtomicReference)))
(definterface ITransientHelper
(editableRoot [^clojure.core.rrb_vector.nodes.NodeManager nm
^clojure.core.ArrayManager am
root])
(editableTail [^clojure.core.ArrayManager am
tail])
(ensureEditable [^clojure.core.rrb_vector.nodes.NodeManager nm
root])
(ensureEditable [^clojure.core.rrb_vector.nodes.NodeManager nm
^clojure.core.ArrayManager am
^java.util.concurrent.atomic.AtomicReference root-edit
current-node
^int shift])
(pushTail [^clojure.core.rrb_vector.nodes.NodeManager nm
^clojure.core.ArrayManager am
^int shift
^int cnt
^java.util.concurrent.atomic.AtomicReference root-edit
current-node
tail-node])
(popTail [^clojure.core.rrb_vector.nodes.NodeManager nm
^clojure.core.ArrayManager am
^int shift
^int cnt
^java.util.concurrent.atomic.AtomicReference root-edit
current-node])
(doAssoc [^clojure.core.rrb_vector.nodes.NodeManager nm
^clojure.core.ArrayManager am
^int shift
^java.util.concurrent.atomic.AtomicReference root-edit
current-node
^int i
val])
(newPath [^clojure.core.rrb_vector.nodes.NodeManager nm
^clojure.core.ArrayManager am
tail
^java.util.concurrent.atomic.AtomicReference edit
^int shift
current-node]))
(popTail [this nm am shift cnt root-edit current-node]
(let [ret (.ensureEditable this nm am root-edit current-node shift)]
(if (.regular nm ret)
(let [subidx (bit-and
(bit-shift-right (unchecked-subtract-int cnt (int 2))
(int shift))
(int p/branch-mask))]
(cond
(> shift p/shift-increment)
(let [child (.popTail this nm am
(unchecked-subtract-int shift p/shift-increment)
cnt ;; TBD: Should this be smaller than cnt?
root-edit
(aget ^objects (.array nm ret) subidx))]
(if (and (nil? child) (zero? subidx))
nil
(let [arr (.array nm ret)]
(aset ^objects arr subidx child)
ret)))
:else
(let [arr (.array nm ret)]
(aset ^objects arr subidx nil)
ret)))
(let [rngs (ranges nm ret)
subidx (unchecked-dec-int (aget rngs p/max-branches))]
(cond
(> shift p/shift-increment)
(let [child (aget ^objects (.array nm ret) subidx)
child-cnt (if (zero? subidx)
(aget rngs 0)
(unchecked-subtract-int
(aget rngs subidx)
(aget rngs (unchecked-dec-int subidx))))
new-child (.popTail this nm am
(unchecked-subtract-int shift p/shift-increment)
child-cnt
root-edit
child)]
(cond
(and (nil? new-child) (zero? subidx))
nil
datastax/fallout
(ns clojure.core.rrb-vector.transients
(:require [clojure.core.rrb-vector.nodes :refer [ranges last-range]])
(:import (clojure.core.rrb_vector.nodes NodeManager)
(clojure.core ArrayManager)
(java.util.concurrent.atomic AtomicReference)))
(definterface ITransientHelper
(editableRoot [^clojure.core.rrb_vector.nodes.NodeManager nm
^clojure.core.ArrayManager am
root])
(editableTail [^clojure.core.ArrayManager am
tail])
(ensureEditable [^clojure.core.rrb_vector.nodes.NodeManager nm
root])
(ensureEditable [^clojure.core.rrb_vector.nodes.NodeManager nm
^clojure.core.ArrayManager am
^java.util.concurrent.atomic.AtomicReference root-edit
current-node
^int shift])
(pushTail [^clojure.core.rrb_vector.nodes.NodeManager nm
^clojure.core.ArrayManager am
^int shift
^int cnt
^java.util.concurrent.atomic.AtomicReference root-edit
current-node
tail-node])
(popTail [^clojure.core.rrb_vector.nodes.NodeManager nm
^clojure.core.ArrayManager am
^int shift
^int cnt
^java.util.concurrent.atomic.AtomicReference root-edit
current-node])
(doAssoc [^clojure.core.rrb_vector.nodes.NodeManager nm
^clojure.core.ArrayManager am
^int shift
^java.util.concurrent.atomic.AtomicReference root-edit
current-node
^int i
val])
(newPath [^clojure.core.rrb_vector.nodes.NodeManager nm
^clojure.core.ArrayManager am
tail
^java.util.concurrent.atomic.AtomicReference edit
^int shift
current-node]))
(popTail [this nm am shift cnt root-edit current-node]
(let [ret (.ensureEditable this nm am root-edit current-node shift)]
(if (.regular nm ret)
(let [subidx (bit-and
(bit-shift-right (unchecked-dec-int cnt) shift)
0x1f)]
(cond
(> shift 5)
(let [child (.popTail this nm am
(unchecked-subtract-int shift 5)
cnt
root-edit
(aget ^objects (.array nm ret) subidx))]
(if (and (nil? child) (zero? subidx))
nil
(let [arr (.array nm ret)]
(aset ^objects arr subidx child)
ret)))
:else
(let [arr (.array nm ret)]
(aset ^objects arr subidx nil)
ret)))
(let [rngs (ranges nm ret)
subidx (bit-and
(bit-shift-right (unchecked-dec-int cnt) shift)
0x1f)
subidx (loop [subidx subidx]
(if (or (zero? (aget rngs (unchecked-inc-int subidx)))
(== subidx 31))
subidx
(recur (unchecked-inc-int subidx))))]
(cond
(> shift 5)
(let [child (aget ^objects (.array nm ret) subidx)
child-cnt (if (zero? subidx)
(aget rngs 0)
(unchecked-subtract-int
(aget rngs subidx)
(aget rngs (unchecked-dec-int subidx))))
new-child (.popTail this nm am
(unchecked-subtract-int subidx 5)
child-cnt
root-edit
child)]
(cond
(and (nil? new-child) (zero? subidx))
nil