Popularity
2.2
Declining
Activity
0.0
Stable
4
2
2
Programming language: Crystal
License: MIT License
Tags:
Algorithms And Data Structures
heap.cr alternatives and similar shards
Based on the "Algorithms and Data structures" category.
Alternatively, view heap.cr alternatives based on common mentions on social networks and blogs.
-
crystalline
A collection of containers & algorithms for the Crystal programming language -
graphlb
graphlb is a crystal library which contains all the graph Data-Structures and Algorithms implemented in crystal-lang. -
markov
⛓ A Crystal library for building Markov Chains and running Markov Processes. -
crystal-linked-list
Simple linked list implementation in Crystal -
kd_tree
Crystal implementation of "K-Dimensional Tree" and "N-Nearest Neighbors" -
Goban
A fast and efficient QR/Micro QR/rMQR Code implementation in Crystal lang -
text
A collection of phonetic algorithms for Crystal. Including; Porter-Stemmer, Soundex, Metaphone, Double Metaphone & White Similarity -
splay_tree_map
This is a Crystal implementation of a Splay Tree; which is a type of binary search tree that is semi-balanced and that tends to self-optimize so that the most accessed items are the fastest to retrieve. -
haversine
Crystal implementation of the Haversine formula to calculate distances between two points given their latitudes and longitudes -
delimiter_tree
A crystal-lang tree structure that is built using a delimiter. -
csuuid
This is a small UUID library that implements a chronologically sortable UUID. -
edits.cr
Edit distance algorithms inc. Jaro, Damerau-Levenshtein, and Optimal Alignment -
murmur3
Crystal implementation of Murmur3 hash algorithm used by Cassandra -
ternary_search_tree
A Crystal implementation of a Ternary Search Tree -
secure-remote-password
Crystal implementation of the Secure Remote Password protocol (SRP-6a)
Collect and Analyze Billions of Data Points in Real Time
Manage all types of time series data in a single, purpose-built database. Run at any scale in any environment in the cloud, on-premises, or at the edge.
Promo
www.influxdata.com
Do you think we are missing an alternative of heap.cr or a related project?
Popular Comparisons
README
heap
useful function that use array as a heap
Installation
Add this to your application's shard.yml
:
dependencies:
heap:
github: chenkovsky/heap.cr
Usage
require "heap"
describe Heap do
# TODO: Write tests
it "nsmallest" do
[99, 1, 88, 2, 3, 56].nsmallest(2).sort.should eq([1, 2])
end
it "arg_nsmallest" do
[99, 1, 88, 2, 3, 56].arg_nsmallest(2).sort.should eq([1, 3])
end
it "nsmallest_by" do
[1, 2, 3].nsmallest_by(2) { |x| -x }.sort.should eq([2, 3])
end
it "arg_nsmallest_by" do
[1, 2, 3].arg_nsmallest_by(2) { |x| -x }.sort.should eq([1, 2])
end
it "merge" do
res = [] of Int32
Array(Int32).merge([1, 2, 3], [4, 5, 6]) do |x|
res << x
end
res.should eq([1, 2, 3, 4, 5, 6])
end
it "mergeby" do
res = [] of Int32
Array(Int32).merge_by([3, 2, 1], [6, 5, 4], key_func: ->(x : Int32) { -x }) do |x|
res << x
end
res.should eq([6, 5, 4, 3, 2, 1])
end
it "nlargest" do
[1, 2, 3].nlargest(2).sort.should eq([2, 3])
end
it "arg_nlargest" do
[1, 2, 3].arg_nlargest(2).sort.should eq([1, 2])
end
it "nlargest_by" do
[1, 2, 3, 4].nlargest_by(2) { |x| -x }.sort.should eq([1, 2])
end
it "arg_nlargest_by" do
[1, 2, 3, 4].arg_nlargest_by(2) { |x| -x }.sort.should eq([0, 1])
end
it "push pop" do
a = [1, 2]
a.heap_push 3
a.heap_pop.should eq(1)
end
it "heapify" do
a = [3, 2, 1]
a.heapify.should eq([1, 2, 3])
end
it "min_max_heap" do
heap = MinMaxHeap(Int32).new
heap << 1
heap << 90
heap << 100
STDERR.puts heap.to_a
arr = [1, 90, 100, 4, 8, 3, 2, 85, 40, 55, 70, 75, 60, 50, 10, 80]
heap = MinMaxHeap(Int32).new arr
heap.pop_last.should eq(100)
heap.pop_last.should eq(90)
heap << 100
heap << 90
arr2 = [] of Int32
while heap.size > 0
arr2 << (heap.pop)
end
arr2.should eq(arr.sort)
heap = MinMaxHeap.new arr, max_size: 4
arr2 = [] of Int32
while heap.size > 0
arr2 << (heap.pop)
end
arr2.should eq([1, 2, 3, 4])
end
end
Development
TODO: Write development instructions here
Contributing
- Fork it ( https://github.com/chenkovsky/heap.cr/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
Contributors
- chenkovsky chenkovsky.chen - creator, maintainer