# candy-utils **Repository Path**: tailipu/candy-utils ## Basic Information - **Project Name**: candy-utils - **Description**: No description available - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-12-31 - **Last Updated**: 2024-12-31 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## @candy/utils package This package provides a simple implementation of a Queue, LinkedList, ArrayList and Stack data structure in TypeScript used in @candy/framework ## Usage #### ArrayList ArrayList is a resizable-array implementation. Each ArrayList instance has a initial capacity. The capacity is the max size of the array. As elements are added to an ArrayList, its capacity grows automatically. ```typescript import ArrayList from '@candy/utils/ArrayList'; const list = new ArrayList(4); assertEquals(list.size(), 0); list.add(1); list.add(2); assertEquals(list.size(), 2); const removed = list.removeAt(0); assertEquals(removed, 1); const index = list.indexOf(2); assertEquals(index, 0); ``` #### LinkedQueue LinkedQueue is a Queue implementation that based on LinkedList. ```typescript import LinkedQueue from '@candy/utils/LinkedQueue'; const queue = new LinkedQueue(); assertEquals(queue.size(), 0); queue.enqueue(1); queue.enqueue(2); assertEquals(queue.size(), 2); const first = queue.dequeue(); assertEquals(first, 1); const second = queue.dequeue(); assertEquals(second, 2); ```