update README.md with a list of supported methods and an example
This commit is contained in:
42
README.md
42
README.md
@@ -1,3 +1,43 @@
|
||||
Java collections for primitives (currently only int) released under [MIT](https://opensource.org/licenses/MIT) license.
|
||||
|
||||
*IntList* is an implementation of a list to store primitive integers. You can add, insert, replace and remove elements in the list. The ints are stored in an int array and the class takes care of growing the array as needed. You can trim the list to reduce the memory overhead.
|
||||
*IntList* and *LongList* are implementations of lists that store primitive integers/longs. The ints/longs are stored in an int/long array and the class takes care of growing the array as needed. You can trim the list to reduce the memory overhead. No dependencies.
|
||||
|
||||
The lists support the following operations:
|
||||
|
||||
* add/remove elements via single and bulk operations
|
||||
* replace elements
|
||||
* sort and shuffle
|
||||
>* the lists know whether or not they are sorted and can leverage that knowledge for searching (binary search), union and intersection
|
||||
* search for elements
|
||||
* union, intersection, retainIf, retainAll removeIf, removeAll
|
||||
* clear and trim are separate methods, so that the list can be re-used without having to reallocate memory
|
||||
* stream support
|
||||
* the lists are serializable and cloneable
|
||||
* the list are **not** thread-safe
|
||||
|
||||
#Examples
|
||||
|
||||
```java
|
||||
import org.lucares.collections.IntList;
|
||||
|
||||
public class Example {
|
||||
public static void main(final String[] args) {
|
||||
final IntList list = IntList.of(1, 3, 5);
|
||||
System.out.println(list + " is sorted: " + list.isSorted());
|
||||
|
||||
list.insert(2, 7);
|
||||
System.out.println(list + " is sorted: " + list.isSorted());
|
||||
|
||||
list.sort();
|
||||
System.out.println(list + " is sorted: " + list.isSorted());
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
Running this program gives the following output:
|
||||
|
||||
```
|
||||
[1, 3, 5] is sorted: true
|
||||
[1, 3, 7, 5] is sorted: false
|
||||
[1, 3, 5, 7] is sorted: true
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user