Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Corrected misplaced docstrings and type hints (found by eastwood). #37

Merged
merged 2 commits into from
Jun 27, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/loom/alg.clj
Original file line number Diff line number Diff line change
Expand Up @@ -545,9 +545,10 @@ can use these functions."
nbrs)]
(recur g src target heur q explored)))))

(defn astar-dist [g src target heur]
(defn astar-dist
"Return the length of the shortest path between src and target using
the A* algorithm"
[g src target heur]
(let [path (astar-path g src target heur)
dist (reduce (fn [c [u v]]
(if (nil? v)
Expand Down
14 changes: 8 additions & 6 deletions src/loom/alg_generic.clj
Original file line number Diff line number Diff line change
Expand Up @@ -404,17 +404,19 @@

(def ^Long bits-per-long (long (Long/SIZE)))

(defn ^Long bm-longs [bits]
(defn ^Long bm-longs
"Return the number of longs required to store bits count bits in a bitmap."
[bits]
(long (Math/ceil (/ bits bits-per-long))))

(defn ^longs bm-new []
(defn bm-new
"Create new empty bitmap."
^longs []
(long-array 1))

(defn ^longs bm-set
[^longs bitmap idx]
(defn bm-set
"Set boolean state of bit in 'bitmap at 'idx to true."
^longs [^longs bitmap idx]
(let [size (max (count bitmap) (bm-longs (inc idx)))
new-bitmap (Arrays/copyOf bitmap ^Long size)
chunk (quot idx bits-per-long)
Expand All @@ -436,9 +438,9 @@
masked-value (bit-and value mask)]
(not (zero? masked-value)))))

(defn ^longs bm-or
(defn bm-or
"Logically OR 'bitmaps together."
[& bitmaps]
^longs [& bitmaps]
(if (empty? bitmaps)
(bm-new)
(let [size (apply max (map count bitmaps))
Expand Down