tyler / bitset Goto Github PK
View Code? Open in Web Editor NEWBitset implementation for Ruby
License: MIT License
Bitset implementation for Ruby
License: MIT License
I'm struggling with this one. I'm getting these errors exclusively in the app I'm trying to use it with:
(gdb) backtrace
#0 0x00007fff81f63616 in __kill ()
#1 0x00007fff82003cca in abort ()
#2 0x00007fff81f1b6f5 in free ()
#3 0x00000001007b855a in bitset_free (bs=0x10756b280) at bitset.c:28
#4 0x000000010003aead in run_final (obj=4384258840) at gc.c:1955
#5 0x000000010003aede in finalize_list (p=0x105527b18) at gc.c:1097
I've been starting at the code for an hour and bashing it from every angle, but it refuses to die under any spec I write.
Any ideas?
As of 2/23/2016, this version no longer builds on the latest Ruby, and it has a couple bugs I am aware of. I invite people to use my version at https://github.com/ericboesch/bitset . Thanks again to Tyler for creating this!
b = Bitset.new(16000)
[5343, 15661, 1500, 6225].each {|i| b[i] = true }
b.to_s.count("1") # => 8 (instead of 4)
b.cardinality # => 36 (instead of 4)
(0...16000).select{|x| b[x]} # => [1500, 1532, 5343, 5375, 6225, 6257, 15629, 15661]
If you have a Bitset of size 64, you get an incorrect cardinality value (always 0).
bits = Bitset.new(64)
bits.set(13,23)
puts bits.cardinality
Results in the value of 0, when it should be 2.
a = Bitset.new(7)
b = ~Bitset.new(7)
a.hamming(b) #=> 64
The problem is that internally the representation is always some number of 64-bit integers, and so unless we explicitly mask out the bits that exist above the actual content bits, it's easy for them to affect operations.
I would like to see bit shifting operators supported (>> and <<)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.