react-hook-data-structure
v0.1.13
Published
React Hook implementation for state-based data structures
Downloads
5
Maintainers
Readme
Hooks
const { ...values, ...methods } = useHook<T>();
useCircularQueue<T>
- Full example
Return object:
current
: element to be usedindex
: position of current element in arraylist
: array used to store values (should be avoided in scenarios where you don't need to access all values at once)next
: update the element to be usedpop
: remove current element from arraypush
: add new element to arrayreset
: remove all elements from array
useDoubleEndedQueue<T>
- Full example
Return object:
current
: element to be usedindex
: position of current element in arraylist
: array used to store values (should be avoided in scenarios where you don't need to access all values at once)next
: update the element to be usedpopStart
: remove first element of arraypopEnd
: remove last element of arraypushStart
: add new element to array at startpushEnd
: add new element to array at endreset
: remove all elements from array
useQueue<T>
- Full example
Return object:
current
: element to be used - at the start of listlist
: array used to store values (should be avoided in scenarios where you don't need to access all values at once)pop
: remove current element from arraypush
: add new element to arrayreset
: remove all elements from array
useStack<T>
- Full example
Return object (just like useQueue
):
current
: element to be used - at the end of listlist
: array used to store values (should be avoided in scenarios where you don't need to access all values at once)pop
: remove current element from arraypush
: add new element to end arrayreset
: remove all elements from array
useRandomArray<T>
- Full example
Return object (just like useQueue
):
current
: element to be usedindex
: position (a random one) of current element in arraylist
: array used to store values (should be avoided in scenarios where you don't need to access all values at once)next
: update the element to be usedpush
: add new element to array at endreset
: remove all elements from array,setArray
: set a new array