Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@algorithm.ts/circular-queue

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@algorithm.ts/circular-queue - npm Package Compare versions

Comparing version 1.0.24 to 2.0.0-alpha.0

8

lib/cjs/index.js

@@ -13,2 +13,3 @@ 'use strict';

init,
free,
front,

@@ -32,2 +33,9 @@ end,

}
function free() {
_MAX_SIZE = 0;
_size = 0;
_queue.length = 0;
_startIndex = -1;
_endIndex = -1;
}
function front() {

@@ -34,0 +42,0 @@ return _size === 0 ? undefined : _queue[_startIndex];

@@ -9,2 +9,3 @@ function createCircularQueue() {

init,
free,
front,

@@ -28,2 +29,9 @@ end,

}
function free() {
_MAX_SIZE = 0;
_size = 0;
_queue.length = 0;
_startIndex = -1;
_endIndex = -1;
}
function front() {

@@ -30,0 +38,0 @@ return _size === 0 ? undefined : _queue[_startIndex];

69

lib/types/index.d.ts

@@ -1,4 +0,67 @@

import type { CircularQueue } from './types';
export * from './types';
/**
* Circular queue.
*
* Circular queue is a queue structure, the main purpose of its design is to
* reuse space as much as possible on the basis of ordinary queues. Circular
* queues usually need to specify the maximum volume C of the collector. If the
* number of elements in the queue exceeds C, only the most recent C elements
* are kept in the queue. Other operations are the same as ordinary queues.
*/
export interface ICircularQueue<T> {
/**
* Initialize the circular queue: Resize the array & reset the start / end index.
* @param MAX_SIZE
*/
init(MAX_SIZE: number): void;
/**
* Free memory.
*/
free(): void;
/**
* Get the front element of the queue.
*/
front(): T | undefined;
/**
* Get the end element of the queue.
*/
end(): T | undefined;
/**
* Popup the front element from the queue.
*/
dequeue(): T | undefined;
/**
* Append an element.
* @param element
* @returns the index assigned to the element just appended
*/
enqueue(element: T): number;
/**
* Gets the element in the queue at the specified index.
*
* @param idx
* @param strickCheck
*/
get(idx: number, strickCheck?: boolean): T | undefined;
/**
* Set the element at the specified index.
*
* @param idx
* @param element
*/
set(idx: number, element: T): boolean;
/**
* Check if the given idx is a valid index of the circular queue.
* @param idx
*/
isValidIndex(idx: number): boolean;
/**
* Get the number of elements in the queue.
*/
size(): number;
/**
* Whether the queue is empty.
*/
isEmpty(): boolean;
}
/**
* Create a circular queue.

@@ -8,2 +71,2 @@ * @param MAX_SIZE

*/
export declare function createCircularQueue<T>(): CircularQueue<T>;
export declare function createCircularQueue<T>(): ICircularQueue<T>;

4

package.json
{
"name": "@algorithm.ts/circular-queue",
"version": "1.0.24",
"version": "2.0.0-alpha.0",
"description": "Circular queue in Typescript",

@@ -42,3 +42,3 @@ "author": {

},
"gitHead": "be5ff5ef055a514bd2f9113b541e9f49ad6008b4"
"gitHead": "f48a558ad6decd6c5eee4b9a999ac085c9e19a22"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc