Skip to content

Commit 9fe36be

Browse files
committed
README tweaks
1 parent f112c54 commit 9fe36be

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

README.md

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,32 @@
22

33
Basic, pure Ruby bit field. Pretty fast (for what it is) and memory efficient. Works well for Bloom filters (the reason I wrote it).
44

5-
Written in 2007 and not updated since then, just bringing it on to GitHub by user request. It used to be called Bitfield and was hosted at http://snippets.dzone.com/posts/show/4234
5+
Written in 2007 and not updated since then, just bringing it on to GitHub by user request. It used to be called Bitfield and was hosted at http://snippets.dzone.com/posts/show/4234 .. I will review the code and bring the docs up to date in due course.
6+
7+
## Installation
8+
9+
gem install bitarray
610

711
## Examples
812

9-
Create a bit field 1000 bits wide
10-
bf = BitField.new(1000)
13+
To use:
14+
15+
require 'bitarray'
16+
17+
Create a bit field 1000 bits wide:
18+
19+
ba = BitArray.new(1000)
20+
21+
Setting and reading bits:
22+
23+
ba[100] = 1
24+
ba[100] .. => 1
25+
ba[100] = 0
1126

12-
Setting and reading bits
13-
bf[100] = 1
14-
bf[100] .. => 1
15-
bf[100] = 0
27+
More:
1628

17-
More
18-
bf.to_s = "10101000101010101" (example)
19-
bf.total_set .. => 10 (example - 10 bits are set to "1")
29+
ba.to_s = "10101000101010101" (example)
30+
ba.total_set .. => 10 (example - 10 bits are set to "1")
2031

2132
## License
2233

0 commit comments

Comments
 (0)