An open API service indexing awesome lists of open source software.

https://github.com/chpengzh/avl-treemap

A TreeMap implement by AVL Algorithm
https://github.com/chpengzh/avl-treemap

Last synced: 2 months ago
JSON representation

A TreeMap implement by AVL Algorithm

Awesome Lists containing this project

README

          

# AVLTreeMap

## What is AVL?

you can find the definition of AVLTree in [Wiki](https://en.wikipedia.org/wiki/AVL_tree)

## Basic Use

`AVLTreeMap` implements interface `Map`

so you can use it as a single map

and of course, it is `thread safe`

> Insert or Update

```java
map.put(someKey, someValue);
```

> Atomic value combination

```
map.put(someKey, (old) -> {
if (old == null) {
return someValue
} else {
return doSomeThing(someValue, old)
}
})
```

> Page Query with offset and limit (Just like `java.util.TreeMap` which is implements by Red Black Tree)

```
//query top n
LinkedHashMap result = map.max(offset, limit);
//query last n
LinkedHashMap result = map.min(offset, limit)
```