Skip to content

Commit bee2067

Browse files
committed
Improve documentation wording
1 parent a5aa2dd commit bee2067

8 files changed

Lines changed: 109 additions & 112 deletions

File tree

CHANGELOG.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,44 @@
11
# Changelog for Abit
22

33
## v0.4.0
4-
* Feature - Implemented fast atomics resetting via `Abit.clear/1` and `Abit.Counter.clear/1`.
5-
* Feature - Implemented bit toggling via `Abit.toggle_bit_at/2` and `Abit.Bitmask.toggle_bit_at/2`.
6-
* Feature - Implemented set theory missing operations: `Abit.difference/2`, `Abit.symmetric_difference/2`, and `Abit.invert/1`.
7-
* Deprecation - `Abit.merge/2` is deprecated in favor of `Abit.union/2` to align with standard set theory terminology.
4+
* Feature - Added fast atomics resetting via `Abit.clear/1` and `Abit.Counter.clear/1`.
5+
* Feature - Added bit toggling via `Abit.toggle_bit_at/2` and `Abit.Bitmask.toggle_bit_at/2`.
6+
* Feature - Added the missing set operations: `Abit.difference/2`, `Abit.symmetric_difference/2`, and `Abit.invert/1`.
7+
* Deprecation - Deprecated `Abit.merge/2` in favor of `Abit.union/2` to align with standard set theory terminology.
88

99
## v0.3.3
10-
* Feature - `Abit.Atomics` implements `serialize/1` and `deserialize/1` functions.
10+
* Feature - Added `Abit.Atomics.serialize/1` and `Abit.Atomics.deserialize/1`.
1111

1212
## v0.3.2
13-
* Fix - compile warning about using `^^^/2` in `Abit.Counter`
13+
* Fix - Fixed a compile warning caused by using `^^^/2` in `Abit.Counter`.
1414

1515
## v0.3.1
16-
* Fix - work with elixir 1.7 by not using Kernel.floor/1 & Kernel.ceil/1
16+
* Fix - Restored compatibility with Elixir 1.7 by avoiding `Kernel.floor/1` and `Kernel.ceil/1`.
1717

1818
## v0.3.0
19-
* BREAKING - removed `Abit.Matrix` module. Extracted to [matrax](https://hex.pm/packages/matrax).
19+
* BREAKING - Removed `Abit.Matrix` and extracted it to [matrax](https://hex.pm/packages/matrax).
2020

2121
## v0.2.4
22-
* Feature - `Abit.Counter` implements `Enumerable` protocol
22+
* Feature - Implemented the `Enumerable` protocol for `Abit.Counter`.
2323

2424
## v0.2.3
25-
* Feature - `Abit.Matrix` implements `add/3`, `exchange/3`, `compare_exchange/4`, `min/1`, `max/1`, ... functions.
26-
* Feature - `Abit.Matrix` implements the `Enumerable` protocol
27-
* Feature - `Abit.Bitmask` implements `to_list/2` function.
28-
* Feature - `Abit` implements `to_list/1` function.
25+
* Feature - Added `add/3`, `exchange/3`, `compare_exchange/4`, `min/1`, `max/1`, and other functions to `Abit.Matrix`.
26+
* Feature - Implemented the `Enumerable` protocol for `Abit.Matrix`.
27+
* Feature - Added `Abit.Bitmask.to_list/2`.
28+
* Feature - Added `Abit.to_list/1`.
2929

3030
## v0.2.2
31-
* Feature - `Abit.Matrix` module for working with atomics as an M x N matrix.
31+
* Feature - Added `Abit.Matrix` for working with atomics as an M x N matrix.
3232

3333
## v0.2.1
34-
* Performance - improvements for the `Abit` & `Abit.Bitmask` module functions
34+
* Performance - Improved the performance of functions in `Abit` and `Abit.Bitmask`.
3535

3636
## v0.2.0
3737

3838
### Abit
39-
* BREAKING - renamed function `set_bit/3` to `set_bit_at/3` to make it consistent with the API of the Bitmask module.
39+
* BREAKING - Renamed `set_bit/3` to `set_bit_at/3` for consistency with the `Abit.Bitmask` API.
4040

4141
### Abit.Counter
42-
* BREAKING - Added an option `wrap_around` to set wrap around behavior. By default wrap around is disabled from now on.
43-
* BREAKING - Using built-in signed/unsigned implementation of integer matching instead of the custom one. Signed integers now wrap around the same way as in Elixir.
44-
* BREAKING - The return value of `put/3` and `add/3` changed to `{:ok, {index, final_value}}` or `{:error, :value_out_of_bounds}` if the option `wrap_around` is set to false and value is out of bounds.
42+
* BREAKING - Added the `wrap_around` option. Wraparound is now disabled by default.
43+
* BREAKING - Replaced the custom signed and unsigned integer matching with the built-in implementation. Signed integers now wrap around as they do in Elixir.
44+
* BREAKING - Changed the return value of `put/3` and `add/3` to `{:ok, {index, final_value}}`, or `{:error, :value_out_of_bounds}` when `wrap_around` is `false` and the value is out of bounds.

README.md

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Documentation can be found at [https://hexdocs.pm/abit](https://hexdocs.pm/abit)
88

99
## Installation
1010

11-
**Note**: it requires OTP-21.2.1 or later.
11+
**Note**: Abit requires OTP 21.2.1 or later.
1212

1313
Add `abit` to your list of dependencies in `mix.exs`:
1414

@@ -24,42 +24,42 @@ end
2424
See [https://hexdocs.pm/abit](https://hexdocs.pm/abit) for full documentation.
2525

2626
### Abit - use `:atomics` as a bit array
27-
* `Abit.bit_count/1` - Returns count of bits in atomics.
28-
* `Abit.union/2` - Unions bits of 2 atomics using Bitwise OR.
29-
* `Abit.intersect/2` - Intersects bits of 2 atomics using Bitwise AND.
30-
* `Abit.difference/2` - Clears bits in left atomics that are set in right using Bitwise AND NOT.
31-
* `Abit.symmetric_difference/2` - Symmetric difference of 2 atomics using Bitwise XOR.
32-
* `Abit.invert/1` - Inverts all bits in atomics using Bitwise NOT.
33-
* `Abit.bit_position/1` - Returns the bit's position in an atomics array.
34-
* `Abit.bit_at/2` - Returns the bit at a given position from atomics.
35-
* `Abit.set_bit_at/3` - Sets the bit in atomics at the given position to the given bit (0 or 1).
36-
* `Abit.toggle_bit_at/2` - Toggles the bit in atomics at the given position.
27+
* `Abit.bit_count/1` - Returns the total number of bits in an atomics reference.
28+
* `Abit.union/2` - Combines two atomics references using bitwise OR.
29+
* `Abit.intersect/2` - Intersects two atomics references using bitwise AND.
30+
* `Abit.difference/2` - Clears bits in the left-hand atomics reference that are set in the right-hand reference using bitwise AND NOT.
31+
* `Abit.symmetric_difference/2` - Computes the symmetric difference of two atomics references using bitwise XOR.
32+
* `Abit.invert/1` - Inverts all bits in an atomics reference using bitwise NOT.
33+
* `Abit.bit_position/1` - Returns a bit's position in an atomics array.
34+
* `Abit.bit_at/2` - Returns the bit at a given position in an atomics reference.
35+
* `Abit.set_bit_at/3` - Sets the bit at a given position in an atomics reference to 0 or 1.
36+
* `Abit.toggle_bit_at/2` - Toggles the bit at a given position in an atomics reference.
3737
* `Abit.clear/1` - Sets all elements in the atomics reference to 0.
38-
* `Abit.set_bits_count/1` - Returns the number of bits set to 1 in atomics.
39-
* `Abit.hamming_distance/2` - Returns the bitwise Hamming distance between the 2 given atomics.
40-
* `Abit.to_list/1` - Returns a flat list of every atomic value converted into a list of bits.
38+
* `Abit.set_bits_count/1` - Returns the number of bits set to 1 in an atomics reference.
39+
* `Abit.hamming_distance/2` - Returns the bitwise Hamming distance between two atomics references.
40+
* `Abit.to_list/1` - Converts every integer in an atomics reference into a flat list of bits.
4141

42-
### Abit.Atomics - utility functions for working with Erlang's :atomics
43-
* `Abit.Atomics.to_list/1` - Converts an :atomics reference to a list of integers.
44-
* `Abit.Atomics.member?/2` - Checks if an integer is present in the :atomics reference.
45-
* `Abit.Atomics.serialize/1` - Serializes an :atomics reference into a binary.
46-
* `Abit.Atomics.deserialize/1` - Deserializes a binary into an :atomics reference.
42+
### Abit.Atomics - utility functions for working with Erlang's `:atomics`
43+
* `Abit.Atomics.to_list/1` - Converts an `:atomics` reference to a list of integers.
44+
* `Abit.Atomics.member?/2` - Checks whether an integer is present in an `:atomics` reference.
45+
* `Abit.Atomics.serialize/1` - Serializes an `:atomics` reference into a binary.
46+
* `Abit.Atomics.deserialize/1` - Deserializes a binary into an `:atomics` reference.
4747

4848
### Abit.Counter - use `:atomics` as an array of N-bit counters
4949
* `Abit.Counter.new/3` - Creates a new array of counters. Returns an `%Abit.Counter{}` struct.
5050
* `Abit.Counter.clear/1` - Sets all elements in the counter array to 0.
51-
* `Abit.Counter.get/2` - Returns the value of counter at the given index.
52-
* `Abit.Counter.put/3` - Puts the value into counter at the given index.
53-
* `Abit.Counter.add/3` - Adds the increment to counter at the given index.
51+
* `Abit.Counter.get/2` - Returns the value of the counter at the given index.
52+
* `Abit.Counter.put/3` - Stores a value in the counter at the given index.
53+
* `Abit.Counter.add/3` - Adds an increment to the counter at the given index.
5454
* `Abit.Counter.member?/2` - Returns `true` if any counter has the given value, `false` otherwise.
55-
* `Abit.Counter.get_all_at_atomic/2` - Returns all counters from atomics at a given index.
55+
* `Abit.Counter.get_all_at_atomic/2` - Returns all counters packed into the atomics element at the given index.
5656

5757
### Abit.Bitmask - helper functions for bitmasks
5858
* `Abit.Bitmask.set_bits_count/1` - Returns the number of bits set to 1 in the given integer.
5959
* `Abit.Bitmask.bit_at/2` - Returns the bit at a given position in the given integer.
6060
* `Abit.Bitmask.set_bit_at/3` - Sets a bit in the given integer at the given position to a given bit (0 or 1).
6161
* `Abit.Bitmask.toggle_bit_at/2` - Toggles the bit at a given position in the given integer.
62-
* `Abit.Bitmask.hamming_distance/2` - Returns the bitwise Hamming distance between the 2 given integers.
62+
* `Abit.Bitmask.hamming_distance/2` - Returns the bitwise Hamming distance between two integers.
6363
* `Abit.Bitmask.to_list/2` - Converts the given integer to a list of bits.
6464

6565

lib/abit.ex

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ defmodule Abit do
5757
import Bitwise
5858

5959
@doc """
60-
Returns total count of bits in atomics `ref`.
60+
Returns the total number of bits in the atomics reference `ref`.
6161
62-
`:atomics` are 64-bit integers, so the total
63-
count of bits is size * 64.
62+
Each element in an atomics reference is a 64-bit integer, so the total
63+
number of bits is `size * 64`.
6464
6565
## Examples
6666
@@ -77,11 +77,9 @@ defmodule Abit do
7777
end
7878

7979
@doc """
80-
Union bits of atomics `ref_a` & `ref_b` using the
81-
bitwise OR operator.
80+
Combines the atomics references `ref_a` and `ref_b` using bitwise OR.
8281
83-
`ref_b` will be unioned into `ref_a`.
84-
Returns `ref_a` mutated.
82+
Mutates and returns `ref_a`.
8583
"""
8684
@spec union(reference, reference) :: reference
8785
def union(ref_a, ref_b) when is_reference(ref_a) and is_reference(ref_b) do
@@ -108,9 +106,9 @@ defmodule Abit do
108106
end
109107

110108
@doc """
111-
Bit intersection of atomics using Bitwise AND operator.
109+
Intersects the atomics references `ref_a` and `ref_b` using bitwise AND.
112110
113-
Returns `ref_a` mutated.
111+
Mutates and returns `ref_a`.
114112
"""
115113
@spec intersect(reference, reference) :: reference
116114
def intersect(ref_a, ref_b) when is_reference(ref_a) and is_reference(ref_b) do
@@ -130,10 +128,10 @@ defmodule Abit do
130128
end
131129

132130
@doc """
133-
Bit difference of atomics using Bitwise AND NOT operators.
131+
Computes the difference between `ref_a` and `ref_b` using bitwise AND NOT.
134132
135133
Clears the bits in `ref_a` that are set in `ref_b`.
136-
Returns `ref_a` mutated.
134+
Mutates and returns `ref_a`.
137135
"""
138136
@doc since: "0.4.0"
139137
@spec difference(reference, reference) :: reference
@@ -154,9 +152,9 @@ defmodule Abit do
154152
end
155153

156154
@doc """
157-
Bit symmetric difference (XOR) of atomics using Bitwise XOR operator.
155+
Computes the symmetric difference of `ref_a` and `ref_b` using bitwise XOR.
158156
159-
Returns `ref_a` mutated.
157+
Mutates and returns `ref_a`.
160158
"""
161159
@doc since: "0.4.0"
162160
@spec symmetric_difference(reference, reference) :: reference
@@ -177,9 +175,9 @@ defmodule Abit do
177175
end
178176

179177
@doc """
180-
Inverts all bits in the atomics reference using Bitwise NOT operator.
178+
Inverts all bits in the atomics reference `ref` using bitwise NOT.
181179
182-
Returns `ref` mutated.
180+
Mutates and returns `ref`.
183181
"""
184182
@doc since: "0.4.0"
185183
@spec invert(reference) :: reference
@@ -278,7 +276,7 @@ defmodule Abit do
278276
@doc """
279277
Returns the position of a bit in `:atomics`.
280278
281-
Returns a 2-tuple containing:
279+
Returns a two-element tuple containing:
282280
* `atomics_index` - the index of the integer in atomics where the bit is located
283281
* `bit_index` - the index of the bit in the integer
284282
@@ -407,8 +405,7 @@ defmodule Abit do
407405
end
408406

409407
@doc """
410-
Returns a flat list of every atomic value converted
411-
into a list of bits from the atomics reference `ref`.
408+
Converts every integer in the atomics reference `ref` into a flat list of bits.
412409
413410
## Examples
414411
ref = :atomics.new(10, signed: false)

lib/abit/atomics.ex

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ defmodule Abit.Atomics do
66
@doc """
77
Converts an :atomics reference to a list of integers.
88
9-
This function takes an :atomics reference and returns a list of integers,
10-
where each integer represents the value stored in each atomic.
9+
This function takes an `:atomics` reference and returns a list containing
10+
the value of each element.
1111
1212
## Parameters
1313
14-
* `atomics_ref` - A reference to an :atomics array.
14+
* `atomics_ref` - A reference to an `:atomics` array.
1515
1616
## Returns
1717
18-
A list of integers representing the values stored in the :atomics array.
18+
A list of integers representing the values stored in the `:atomics` array.
1919
2020
## Examples
2121
@@ -41,19 +41,19 @@ defmodule Abit.Atomics do
4141
end
4242

4343
@doc """
44-
Checks if an integer is present in the :atomics reference.
44+
Checks whether an integer is present in the `:atomics` reference.
4545
46-
This function checks if the given integer exists as a value in any of the
47-
atomics within the provided :atomics reference.
46+
This function checks whether the given integer matches any element in the
47+
provided `:atomics` reference.
4848
4949
## Parameters
5050
51-
* `atomics_ref` - A reference to an :atomics array.
51+
* `atomics_ref` - A reference to an `:atomics` array.
5252
* `int` - The integer to search for.
5353
5454
## Returns
5555
56-
Returns `true` if the integer is found in the :atomics array, `false` otherwise.
56+
Returns `true` if the integer is found in the `:atomics` array, or `false` otherwise.
5757
5858
## Examples
5959
@@ -97,18 +97,18 @@ defmodule Abit.Atomics do
9797
end
9898

9999
@doc """
100-
Serializes an :atomics reference into a binary.
100+
Serializes an `:atomics` reference into a binary.
101101
102-
This function takes an :atomics reference and returns a binary where each
103-
64-bit integer in the :atomics array is encoded in big-endian format.
102+
This function takes an `:atomics` reference and returns a binary in which each
103+
64-bit integer is encoded in big-endian format.
104104
105105
## Parameters
106106
107-
* `atomics_ref` - A reference to an :atomics array.
107+
* `atomics_ref` - A reference to an `:atomics` array.
108108
109109
## Returns
110110
111-
A binary containing the serialized :atomics data.
111+
A binary containing the serialized `:atomics` data.
112112
113113
## Examples
114114
@@ -142,18 +142,18 @@ defmodule Abit.Atomics do
142142
end
143143

144144
@doc """
145-
Deserializes a binary into an :atomics reference.
145+
Deserializes a binary into an `:atomics` reference.
146146
147147
This function takes a binary that was previously serialized using `serialize/1`
148-
and reconstructs an :atomics reference from it.
148+
and reconstructs an `:atomics` reference from it.
149149
150150
## Parameters
151151
152-
* `binary` - A binary containing the serialized :atomics data.
152+
* `binary` - A binary containing the serialized `:atomics` data.
153153
154154
## Returns
155155
156-
A reference to a new :atomics array containing the deserialized data.
156+
A reference to a new `:atomics` array containing the deserialized data.
157157
158158
## Examples
159159

lib/abit/bitmask.ex

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
defmodule Abit.Bitmask do
22
@moduledoc """
3-
Functions for working with bits & integer bitmasks.
3+
Functions for working with bits and integer bitmasks.
44
"""
55

66
import Bitwise
@@ -37,7 +37,7 @@ defmodule Abit.Bitmask do
3737
end
3838

3939
@doc """
40-
Returns bit at `bit_index` in the given `integer`.
40+
Returns the bit at `bit_index` in the given `integer`.
4141
4242
## Examples
4343
@@ -120,8 +120,8 @@ defmodule Abit.Bitmask do
120120
@doc """
121121
Converts the given `integer` to a list of bits.
122122
123-
`size` is the size of the bitstring you want the integer to be
124-
converted to before creating a list from it.
123+
`size` specifies the bitstring size to use before converting the integer
124+
to a list.
125125
126126
## Examples
127127

0 commit comments

Comments
 (0)