Skip to content

Commit c4e0ed6

Browse files
committed
Fixed readme
1 parent b77e895 commit c4e0ed6

File tree

1 file changed

+35
-35
lines changed

1 file changed

+35
-35
lines changed

README.md

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ BitSet.js is an infinite [Bit-Array](http://en.wikipedia.org/wiki/Bit_array) (ak
88

99
## Examples
1010

11-
###Basic usage
11+
### Basic usage
1212

1313
```javascript
1414
let bs = new BitSet;
1515
bs.set(128, 1); // Set bit at position 128
1616
console.log(bs.toString(16)); // Print out a hex dump with one bit set
1717
```
1818

19-
###Flipping bits
19+
### Flipping bits
2020

2121
```javascript
2222
let bs = new BitSet;
@@ -31,14 +31,14 @@ if (str === "111111111111111111111111111000000011111111111111111111111111111") {
3131
}
3232
```
3333

34-
###Range Set
34+
### Range Set
3535

3636
```javascript
3737
let bs = new BitSet;
3838
bs.setRange(10, 18, 1); // Set a 1 between 10 and 18, inclusive
3939
```
4040

41-
###User permissions
41+
### User permissions
4242

4343
If you want to store user permissions in your database and use BitSet for the bit twiddling, you can start with the following Linux-style snippet:
4444
```javascript
@@ -56,7 +56,7 @@ let world = new BitSet(P_EXEC);
5656
console.log("0" + user.toString(8) + group.toString(8) + world.toString(8));
5757
```
5858

59-
##Installation
59+
## Installation
6060

6161

6262
```
@@ -67,7 +67,7 @@ or
6767
bower install bitset.js
6868
```
6969

70-
##Using BitSet.js with the browser
70+
## Using BitSet.js with the browser
7171

7272
```html
7373
<script src="bitset.js"></script>
@@ -76,7 +76,7 @@ bower install bitset.js
7676
</script>
7777
```
7878

79-
##Using BitSet.js with require.js
79+
## Using BitSet.js with require.js
8080

8181
```html
8282
<script src="require.js"></script>
@@ -88,7 +88,7 @@ function(BitSet) {
8888
</script>
8989
```
9090

91-
##Constructor
91+
## Constructor
9292

9393
The default `BitSet` constructor accepts a single value of one the following types :
9494

@@ -106,117 +106,117 @@ The default `BitSet` constructor accepts a single value of one the following typ
106106
- A BitSet object, which get copied over
107107

108108

109-
##Functions
109+
## Functions
110110

111111

112112
The data type Mixed can be either a BitSet object, a String or an integer representing a native bitset with 31 bits.
113113

114114

115-
###BitSet set(ndx[, value=1])
115+
### BitSet set(ndx[, value=1])
116116

117117
Mutable; Sets value 0 or 1 to index `ndx` of the bitset
118118

119119
int get(ndx)
120120
---
121121
Gets the value at index ndx
122122

123-
###BitSet setRange(from, to[, value=1])
123+
### BitSet setRange(from, to[, value=1])
124124

125125
Mutable; Helper function for set, to set an entire range to a given value
126126

127-
###BitSet clear([from[, to]])
127+
### BitSet clear([from[, to]])
128128

129129
Mutable; Sets a portion of a given bitset to zero
130130

131131
- If no param is given, the whole bitset gets cleared
132132
- If one param is given, the bit at this index gets cleared
133133
- If two params are given, the range is cleared
134134

135-
###BitSet slice([from[, to]])
135+
### BitSet slice([from[, to]])
136136

137137
Immutable; Extracts a portion of a given bitset as a new bitset
138138

139139
- If no param is given, the bitset is getting cloned
140140
- If one param is given, the index is used as offset
141141
- If two params are given, the range is returned as new BitSet
142142

143-
###BitSet flip([from[, to]])
143+
### BitSet flip([from[, to]])
144144

145145
Mutable; Toggles a portion of a given bitset
146146

147147
- If no param is given, the bitset is inverted
148148
- If one param is given, the bit at the index is toggled
149149
- If two params are given, the bits in the given range are toggled
150150

151-
###BitSet not()
151+
### BitSet not()
152152

153153
Immutable; Calculates the bitwise complement
154154

155-
###BitSet and(Mixed x)
155+
### BitSet and(Mixed x)
156156

157157
Immutable; Calculates the bitwise intersection of two bitsets
158158

159-
###BitSet or(Mixed x)
159+
### BitSet or(Mixed x)
160160

161161
Immutable; Calculates the bitwise union of two bitsets
162162

163-
###BitSet xor(Mixed x)
163+
### BitSet xor(Mixed x)
164164

165165
Immutable; Calculates the bitwise xor between two bitsets
166166

167-
###BitSet andNot(Mixed x)
167+
### BitSet andNot(Mixed x)
168168

169169
Immutable; Calculates the bitwise difference of two bitsets (this is not the nand operation!)
170170

171-
###BitSet clone()
171+
### BitSet clone()
172172

173173
Immutable; Clones the actual object
174174

175-
###Array toArray()
175+
### Array toArray()
176176

177177
Returns an array with all indexes set in the bitset
178178

179-
###String toString([base=2])
179+
### String toString([base=2])
180180

181181
Returns a string representation with respect to the base
182182

183-
###int cardinality()
183+
### int cardinality()
184184

185185
Calculates the number of bits set
186186

187-
###int msb()
187+
### int msb()
188188

189189
Calculates the most significant bit (the left most)
190190

191-
###int ntz()
191+
### int ntz()
192192

193193
Calculates the number of trailing zeros (zeros on the right). If all digits are zero, `Infinity` is returned, since BitSet.js is an arbitrary large bit vector implementation.
194194

195-
###int lsb()
195+
### int lsb()
196196

197197
Calculates the least significant bit (the right most)
198198

199-
###bool isEmpty()
199+
### bool isEmpty()
200200

201201
Checks if the bitset has all bits set to zero
202202

203-
###bool equals()
203+
### bool equals()
204204

205205
Checks if two bitsets are the same
206206

207-
###BitSet.fromBinaryString(str)
207+
### BitSet.fromBinaryString(str)
208208

209209
Alternative constructor to pass with a binary string
210210

211-
###BitSet.fromHexString(str)
211+
### BitSet.fromHexString(str)
212212

213213
Alternative constructor to pass a hex string
214214

215-
###BitSet.Random([n=32])
215+
### BitSet.Random([n=32])
216216

217217
Create a random BitSet with a maximum length of n bits
218218

219-
##Iterator Interface
219+
## Iterator Interface
220220

221221
A `BitSet` object is iterable. The iterator gets all bits up to the most significant bit. If no bits are set, the iteration stops immediately.
222222

@@ -230,11 +230,11 @@ for (let b of bs) {
230230
Note: If the bitset is inverted so that all leading bits are 1, the iterator must be stopped by the user!
231231

232232

233-
##Coding Style
233+
## Coding Style
234234

235235
As every library I publish, BitSet.js is also built to be as small as possible after compressing it with Google Closure Compiler in advanced mode. Thus the coding style orientates a little on maxing-out the compression rate. Please make sure you keep this style if you plan to extend the library.
236236

237-
##Building the library
237+
## Building the library
238238

239239
After cloning the Git repository run:
240240

@@ -243,7 +243,7 @@ npm install
243243
npm run build
244244
```
245245

246-
##Run a test
246+
## Run a test
247247

248248
Testing the source against the shipped test suite is as easy as
249249

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy