nv-facutil-cache-cursor
v1.0.5
Published
nv-facutil-cache-cursor =============== - simple cache with cursor - forward ,backword, push,pop, push\_and\_forward ,pop\_and\_backward
Downloads
13
Maintainers
Readme
nv-facutil-cache-cursor
- simple cache with cursor
- forward ,backword, push,pop, push_and_forward ,pop_and_backward
install
- npm install nv-facutil-cache-cursor
usage
const Cache = require("nv-facutil-cache-cursor");
example
var cache = new Cache(4,null) // new Cache(max_size,noexist_sign)
cache
cache.cursor_
/*
> cache
Cache(0) [ max_size: 4 ,noexist:null]
> cache.cursor_
-1
*/
cache.push(10)
cache.push(20)
cache.push(30)
cache.push(40)
cache
cache.cursor_
/*
> cache
Cache(4) [ 10, 20, 30, 40, max_size: 4 ,noexist:null]
> cache.cursor_
-1
*/
cache.forward(2)
cache.cursor_
cache.curr_
/*
> cache
Cache(4) [ 10, 20, 30, 40, max_size: 4 ,noexist:null]
> cache.forward(2)
20
> cache.cursor_
1
> cache.curr_
20
>
*/
cache.push_and_forward(50)
cache
cache.cursor_
cache.curr_
/*
> cache.push_and_forward(50)
40
>
> cache
Cache(4) [ 20, 30, 40, 50, max_size: 4 ,noexist:null]
> cache.cursor_
2
> cache.curr_
40
>
*/
cache.pop_and_backward()
cache
cache.cursor_
cache.curr_
/*
cache.pop_and_backward()
30
> cache
Cache(3) [ 20, 30, 40, max_size: 4 ,noexist:null]
> cache.cursor_
1
> cache.curr_
30
>
*/
cache.prev_
cache.pprev_
cache.next_
cache.nnext_
/*
> cache.curr_
30
> cache.prev_
20
> cache.pprev_
null
> cache.next_
40
> cache.nnext_
null
*/
SLICE
> c = new C(4)
Cache(0) [ max_size: 4, noexist: undefined ]
>
> c.push(10)
> c.push(20)
> c.push(30)
> c.push(40)
> c.forward()
10
> c.forward()
20
> c
Cache(4) [ 10, 20, 30, 40, max_size: 4, noexist: undefined ]
>
> c.cursor_
1
> c.slice_lt_cursor_
Cache(1) [ 10, max_size: 1, noexist: undefined ]
>
> c.slice_le_cursor_
Cache(2) [ 10, 20, max_size: 2, noexist: undefined ]
>
> c.slice_gt_cursor_
Cache(2) [ 30, 40, max_size: 2, noexist: undefined ]
>
> c.slice_ge_cursor_
Cache(3) [ 20, 30, 40, max_size: 3, noexist: undefined ]
>
METHODS
cache.b cache.backward cache.can_back_max_steps_
cache.can_forward_max_steps_ cache.clear cache.constructor
cache.curr_ cache.f cache.forward
cache.fst_ cache.is_cant_backward_one cache.is_cant_forward_one
cache.is_empty cache.is_pc_at_max cache.is_pc_at_min
cache.lst_ cache.max_pc_ cache.min_pc_
cache.next_ cache.nnext_ cache.pc_
cache.pop cache.pop_and_backward cache.pprev_
cache.prev_ cache.push cache.push_and_forward
cache.safe_pop
c.slice_ge_cursor_
c.slice_gt_cursor_
c.slice_le_cursor_
c.slice_lt_cursor_
cache.length cache.max_size
APIS
LICENSE
- ISC