Public Vars

Back

bit-shift-left (clj)

(source)

function

(bit-shift-left x n)
Bitwise shift left

Examples

typedclojure/typedclojure
(ns ^:no-doc typed.ann.clojure
  "Type annotations for the base Clojure distribution."
  #?(:cljs (:require-macros [typed.ann-macros.clojure :as macros]))
  (:require [clojure.core :as cc]
            [typed.clojure :as t]
            #?(:clj [typed.ann-macros.clojure :as macros])
            #?(:clj typed.ann.clojure.jvm) ;; jvm annotations
            #?(:clj clojure.core.typed))
  #?(:clj
     (:import (clojure.lang PersistentHashSet PersistentList
                            APersistentMap #_IPersistentCollection
                            #_ITransientSet
                            IRef)
              (java.util Comparator Collection))))

cc/bit-not [t/AnyInteger :-> t/AnyInteger]
cc/bit-and [t/AnyInteger (t/+ t/AnyInteger) :-> t/AnyInteger]
cc/bit-or [t/AnyInteger (t/+ t/AnyInteger) :-> t/AnyInteger]
cc/bit-xor [t/AnyInteger (t/+ t/AnyInteger) :-> t/AnyInteger]
cc/bit-and-not [t/AnyInteger (t/+ t/AnyInteger) :-> t/AnyInteger]
cc/bit-clear [t/AnyInteger t/AnyInteger :-> t/AnyInteger]
cc/bit-set [t/AnyInteger t/AnyInteger :-> t/AnyInteger]
cc/bit-flip [t/AnyInteger t/AnyInteger :-> t/AnyInteger]
cc/bit-test [t/AnyInteger t/AnyInteger :-> t/AnyInteger]
cc/bit-shift-left [t/AnyInteger t/AnyInteger :-> t/AnyInteger]
cc/bit-shift-right [t/AnyInteger t/AnyInteger :-> t/AnyInteger]
cc/unsigned-bit-shift-right [t/AnyInteger t/AnyInteger :-> t/AnyInteger]
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)))

    (pushTail [this nm am shift cnt root-edit current-node tail-node]
      (let [ret (.ensureEditable this nm am root-edit current-node shift)]
        (if (.regular nm ret)
          (do (loop [n ret shift shift]
                (let [arr    (.array nm n)
                      subidx (bit-and (bit-shift-right (dec cnt) shift) 0x1f)]
                  (if (== shift 5)
                    (aset ^objects arr subidx tail-node)
                    (let [child (aget ^objects arr subidx)]
                      (if (nil? child)
                        (aset ^objects arr subidx
                              (.newPath this nm am
                                        (.array nm tail-node)
                                        root-edit
                                        (unchecked-subtract-int shift 5)
                                        tail-node))
                        (let [editable-child
                              (.ensureEditable this nm am
                                               root-edit
                                               child
                                               (unchecked-subtract-int
                                                shift 5))]
                          (aset ^objects arr subidx editable-child)
                          (recur editable-child (- shift 5))))))))
              ret)
          (let [arr  (.array nm ret)
                rngs (ranges nm ret)
                li   (unchecked-dec-int (aget rngs 32))
                cret (if (== shift 5)
                       nil
                       (let [child (.ensureEditable this nm am
                                                    root-edit
                                                    (aget ^objects arr li)
                                                    (unchecked-subtract-int
                                                     shift 5))
                             ccnt  (if (pos? li)
                                     (unchecked-subtract-int
                                      (aget rngs li)
                                      (aget rngs (unchecked-dec-int li)))
                                     (aget rngs 0))]
                         (if-not (== ccnt (bit-shift-left 1 shift))
                           (.pushTail this nm am
                                      (unchecked-subtract-int shift 5)
                                      (unchecked-inc-int ccnt)
                                      root-edit
                                      child
                                      tail-node))))]
            (if cret
              (do (aset ^objects arr li cret)
                  (aset rngs li (unchecked-add-int (aget rngs li) 32))
                  ret)
              (do (aset ^objects arr (inc li)
                        (.newPath this nm am
                                  (.array nm tail-node)
                                  root-edit
                                  (unchecked-subtract-int shift 5)
                                  tail-node))
                  (aset rngs (unchecked-inc-int li)
                        (unchecked-add-int (aget rngs li) 32))
                  (aset rngs 32 (unchecked-inc-int (aget rngs 32)))
                  ret))))))