Skip to content

Commit 68879bc

Browse files
author
George B
authored
getting dev up to speed after first release
Merge pull request #4 from Abductcows/master
2 parents e3d2328 + 2f237c7 commit 68879bc

File tree

7 files changed

+149
-17
lines changed

7 files changed

+149
-17
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
name: Bug report
3+
about: Create a report to identify unintended behaviour
4+
title: "[BUG] - ..."
5+
labels: bug
6+
assignees: ''
7+
8+
---
9+
10+
**Describe the bug**
11+
A clear and concise description of what the bug is.
12+
13+
**To Reproduce**
14+
Steps to reproduce the behaviour:
15+
1. Go to '...'
16+
2. Click on '....'
17+
3. Scroll down to '....'
18+
4. See error
19+
20+
**Expected behavior**
21+
A clear and concise description of what you expected to happen.
22+
23+
**Screenshots**
24+
If applicable, add screenshots to help explain your problem.
25+
26+
**Additional context**
27+
Add any other context about the problem here.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
name: Design or Implementation improvement
3+
about: Suggest a change to improve the internal logic or performance of the class
4+
title: "[Design/Implementation] - ..."
5+
labels: ok but this is better
6+
assignees: ''
7+
8+
---
9+
10+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: "[Feature Request] - ..."
5+
labels: feature request
6+
assignees: ''
7+
8+
---
9+
10+
**Is your feature request related to a problem? Please describe.**
11+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12+
13+
**Describe the solution you'd like**
14+
A clear and concise description of what you want to happen.
15+
16+
**Describe alternatives you've considered**
17+
A clear and concise description of any alternative solutions or features you've considered.
18+
19+
**Additional context**
20+
Add any other context or screenshots about the feature request here.

CONTRIBUTING.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Contributing to Java BitArray
2+
3+
Thank you for taking an interest in this project. You can contribute by writing code to fix/extend the features or use/test the class itself.
4+
5+
You should start by [creating an issue](https://github.com/Abductcows/java-bit-array/issues) and relaying your idea or findings. You can find issue templates [here](https://github.com/Abductcows/java-bit-array/issues/new/choose) but using them is not mandatory.
6+
7+
8+
### Bug reports
9+
10+
Create an [issue](https://github.com/Abductcows/java-bit-array/issues) with the [bug](https://github.com/Abductcows/java-bit-array/labels/bug) label and state the problem. A "good" bug report usually contains:
11+
- A quick summary of the use case and context
12+
- What you expected to see
13+
- What actually happened
14+
- Steps to reproduce the unexpected behaviour if not clear
15+
- Code snippets, debugger messages or screenshots if appropriate
16+
17+
### Code contributions
18+
19+
This repository uses [Maven](https://maven.apache.org/) for project management and [SemVer 2.0](https://semver.org/) for version specification. Source file format is **UTF-8 CRLF** with **4 spaces** for indentation. Development takes place in the [dev](https://github.com/Abductcows/java-bit-array/tree/dev) branch and is eventually integrated in the next release.
20+
21+
Before writing any code, you should state your intent by creating an [issue](https://github.com/Abductcows/java-bit-array/issues) with the appropriate tag. You could also ask to be assigned to an existing issue. Upon confirmation, follow the usual fork-pull request pattern (and increment product version):
22+
23+
- [Fork](https://docs.github.com/en/github/getting-started-with-github/fork-a-repo#fork-an-example-repository) this repository (top right corner)
24+
- [Clone](https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/cloning-a-repository#cloning-a-repository-using-the-command-line) your new repository to your machine and make the code changes
25+
- **Important:** increment version number in [pom.xml](https://github.com/Abductcows/java-bit-array/blob/dev/pom.xml) and Javadoc `@version` in compliance with [SemVer 2.0](https://semver.org/)
26+
- [Commit and push](https://docs.github.com/en/github/managing-files-in-a-repository/adding-a-file-to-a-repository-using-the-command-line) your changes to your forked repository
27+
- [Create a pull request](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request#creating-the-pull-request) from your repository's dev branch to this repository.
28+
29+
Please note that pull requests which do not comply with the rules aforementioned or make unnecessary whitespace modifications at unrelated locations will not be admitted unless revised.
30+
31+
### License
32+
33+
By contributing to this repository, you agree that your contributions will be licensed under the project's license: Apache License, Version 2.0

README.md

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,46 @@
1-
# java-bit-array
1+
# Java BitArray
22

3-
Java array of bit values that uses 1 bit per entry
3+
[![Latest release][latest-release-shield]][latest-release-url]  
4+
[![Open Issues][open-issues-shield]][open-issues-url]  
5+
[![Contributors][contributors-shield]][contributors-url]
46

5-
Proper readme, Javadoc and first release coming soon
7+
### Motivation
8+
This class is a replacement for the `ArrayList<Boolean>` type when working with its `List` interface. It boasts higher performance in add, remove and set operations and requires less memory for storing the same elements.
9+
10+
The BitArray is by all means an array; it is random access and all elements have contiguous indices at all times. Its behaviour is meant to be indistinguishable from ArrayList in order for programmers to be able to substitute it for the latter and benefit from its performance advantage.
11+
12+
### Few details
13+
Internally the array stores the boolean elements in an array of long primitives. These long primitives essentially form a sequence of bits; their chained bit representation in 2's complement. Boolean elements are converted to and from their bit equivalent to perform insertions, deletions etc. With the appropriate bitwise operations new elements can be added at a specific index and elements already in the array can be shifted to preserve the previous order. Thanks to that hack, element shifting and array resizing is much cheaper, all while the elements themselves occupy less space in memory.
14+
15+
### Performance
16+
With regard to the difference in performance, I have a [temporary benchmark](https://github.com/Abductcows/java-bit-array/blob/dev/src/test/java/gr/geompokon/bitarray/BitArrayVsArrayListBenchmarkTest.java) file for you to test. I am looking into creating a more trustworthy benchmark using a benchmark framework like [JMH](https://github.com/openjdk/jmh) in order to be able to publish some results with confidence. If you have experience doing that and want to contribute, feel free to start an [issue](https://github.com/Abductcows/java-bit-array/issues).
17+
18+
### Disclaimer
19+
As you can tell from the project version and creation date this class is very new and not battle-tested. As such I would discourage you from using it in a serious application just yet.
20+
21+
# Getting Started
22+
You will need the class and source files. You can grab the [latest release](https://github.com/Abductcows/java-bit-array/releases/latest) (built for jdk-11) or download the project and run `mvn package/install` yourself. Releases contain a zip file with separate jars for classes, sources and javadoc. Include at least the class jar in your project and you will be able to use the BitArray. Looks like you are good to go.
23+
24+
### Versioning
25+
The project uses [SemVer](https://semver.org/) for versioning.
26+
27+
### Contributions and future of this project
28+
I would like to work on this project with anyone willing to contribute. My estimation of the rough priority of actions needed is:
29+
30+
- Testing/debugging: Write better and well documented tests to enhance confidence
31+
- Benchmarking: Give ArrayList a run for their money
32+
- Optimizing: 'cause why not. Maybe override a few of the AbstractList's default implementations
33+
- New features: Not sure what to add, suggestions very welcome
34+
35+
If you want to contribute, check out [CONTRIBUTING.md](https://github.com/Abductcows/java-bit-array/blob/master/CONTRIBUTING.md) for more info.
36+
37+
### Authors
38+
- *George Bouroutzoglou* (geompokon@csd.auth.gr)
39+
40+
41+
[open-issues-url]: https://github.com/Abductcows/java-bit-array/issues
42+
[open-issues-shield]: https://img.shields.io/github/issues/abductcows/java-bit-array
43+
[contributors-url]: https://github.com/Abductcows/java-bit-array/graphs/contributors
44+
[contributors-shield]: https://img.shields.io/github/contributors/abductcows/java-bit-array
45+
[latest-release-shield]: https://img.shields.io/github/v/release/abductcows/java-bit-array?sort=semver
46+
[latest-release-url]: https://github.com/Abductcows/java-bit-array/releases/latest

pom.xml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,11 @@
6565
<version>3.2.0</version>
6666
<configuration>
6767
<javadocExecutable>${java.home}/bin/javadoc</javadocExecutable>
68-
<includes>
69-
<include>${project.basedir}/LICENSE</include>
70-
</includes>
68+
<level>public</level>
69+
70+
<defaultVersion>${project.version}</defaultVersion>
71+
<fixTags>version</fixTags>
72+
<force>true</force>
7173
</configuration>
7274
<executions>
7375
<execution>

src/main/java/gr/geompokon/bitarray/BitArray.java

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
* Class that models an array of {@code Booleans} with the {@link java.util.List} interface.
2323
*
2424
* <p>
25-
* The aim of this class is to enhance the performance of common operations such as {@code add}, {@code remove} and
26-
* {@code set} while also minimizing its memory footprint. This class was made explicitly to replace {@link ArrayList}
27-
* when working with {@code Boolean} elements.
25+
* This class was made explicitly to replace {@link java.util.ArrayList} when working with {@code Boolean} elements.
26+
* It aims to enhance the performance of common operations such as {@code add}, {@code remove} and {@code set} while
27+
* also minimizing its memory footprint.
2828
* </p>
2929
*
3030
* <p>
@@ -50,7 +50,6 @@
5050
* not follow the one bit per entry principle.
5151
* </p>
5252
*
53-
* @author George Bouroutzoglou (geompokon@csd.auth.gr)
5453
* @version 1.0.0
5554
* @see java.util.List
5655
* @see java.util.AbstractList
@@ -79,7 +78,7 @@ public final class BitArray extends AbstractList<Boolean> implements RandomAcces
7978
private int elements;
8079

8180
/**
82-
* Default constructor. Sets initial capacity to {@link #DEFAULT_CAPACITY}.
81+
* Default constructor. Sets initial capacity to 64
8382
*/
8483
public BitArray() {
8584
this(DEFAULT_CAPACITY);
@@ -109,7 +108,7 @@ public BitArray(int initialCapacity) {
109108
* </p>
110109
*
111110
* @param other the collection supplying the elements
112-
* @throws NullPointerException if the collection is null
111+
* @throws java.lang.NullPointerException if the collection is null
113112
*/
114113
public BitArray(Collection<? extends Boolean> other) {
115114
Objects.requireNonNull(other);
@@ -147,7 +146,7 @@ private void initMembers(int initialCapacity) {
147146
*
148147
* @param index array index to insert the element in
149148
* @param bit the boolean value to be inserted
150-
* @throws IndexOutOfBoundsException if index is out of array insertion bounds
149+
* @throws java.lang.IndexOutOfBoundsException if index is out of array insertion bounds
151150
*/
152151
public void add(int index, Boolean bit) {
153152
Objects.requireNonNull(bit);
@@ -194,7 +193,7 @@ public Boolean get(int index) {
194193
* @param index index of the array element to be changed
195194
* @param bit the new value of the array element
196195
* @return boolean value of the previous bit at that index
197-
* @throws IndexOutOfBoundsException if index is out of array bounds
196+
* @throws java.lang.IndexOutOfBoundsException if index is out of array bounds
198197
*/
199198
public Boolean set(int index, Boolean bit) {
200199
Objects.requireNonNull(bit);
@@ -516,9 +515,9 @@ public BitArray clone() {
516515
*
517516
* <p>
518517
* The string consists of the number of elements in the array and a list of the elements in a human readable
519-
* format. Exact representation is "Size = SIZE, [((0 | 1) + ' ')*]" where SIZE is a non negative integer and
520-
* the list of elements consists of opening square brackets ([), zero or more bits (single digit ones or zeros)
521-
* separated by spaces and closing square brackets.
518+
* format. Exact representation is "Size = SIZE, [(((0 | 1) + ' ')* (0 | 1))?]" where SIZE is a non negative integer
519+
* and '+' is the concatenation operator. The list of elements consists of opening square brackets ([), zero or more
520+
* bits (single digit ones or zeros) separated by spaces and closing square brackets.
522521
* </p>
523522
* <p>
524523
* Examples:<br>

0 commit comments

Comments
 (0)