New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

sb-js-data-structures

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sb-js-data-structures - npm Package Compare versions

Comparing version 1.0.6 to 1.0.7

docs/doubly-linked-list.png

6

bin/src/index.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Stack = exports.SortedList = exports.Queue = exports.LinkedList = exports.HashTable = exports.BinarySearchTree = void 0;
exports.Stack = exports.SortedList = exports.Queue = exports.LinkedList = exports.HashTable = exports.DoublyLinkedList = exports.BinarySearchTree = void 0;
var binary_search_tree_1 = require("./core/binary-search-tree");
Object.defineProperty(exports, "BinarySearchTree", { enumerable: true, get: function () { return binary_search_tree_1.BinarySearchTree; } });
var doubly_linked_list_1 = require("./core/doubly-linked-list");
Object.defineProperty(exports, "DoublyLinkedList", { enumerable: true, get: function () { return doubly_linked_list_1.DoublyLinkedList; } });
var hash_table_1 = require("./core/hash-table");

@@ -16,2 +18,2 @@ Object.defineProperty(exports, "HashTable", { enumerable: true, get: function () { return hash_table_1.HashTable; } });

Object.defineProperty(exports, "Stack", { enumerable: true, get: function () { return stack_1.Stack; } });
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEsZ0VBQTREO0FBQW5ELHNIQUFBLGdCQUFnQixPQUFBO0FBQ3pCLGdEQUE2QztBQUFwQyx1R0FBQSxTQUFTLE9BQUE7QUFDbEIsa0RBQStDO0FBQXRDLHlHQUFBLFVBQVUsT0FBQTtBQUNuQixzQ0FBb0M7QUFBM0IsOEZBQUEsS0FBSyxPQUFBO0FBQ2Qsa0RBQStDO0FBQXRDL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YXJjaC10cmVlJ1xuZXhwb3J0IHsgRG91Ymx5TGlua2VkTGlzdCB9IGZyb20gJy4vY29yZS9kb3VibHktbGlua2VkLWxpc3QnXG5leHBvcnQgeyBIYXNoVGFibGUgfSBmcm9tICcuL2NvcmUvaGFzaC10YWJsZSdcbmV4cG9ydCB7IExpbmtlZExpc3QgfSBmcm9tICcuL2NvcmUvbGlua2VkLWxpc3QnXG5leHBvcnQgeyBRdWV1ZSB9IGZyb20gJy4vY29yZS9xdWV1ZSdcbmV4cG9ydCB7IFNvcnRlZExpc3QgfSBmcm9tICcuL2NvcmUvc29ydGVkLWxpc3QnXG5leHBvcnQgeyBTdGFjayB9IGZyb20gJy4vY29yZS9zdGFjaydcbiJdfQ==
{
"name": "sb-js-data-structures",
"version": "1.0.6",
"version": "1.0.7",
"repository": {

@@ -46,3 +46,3 @@ "type": "git",

"prepublish": "yarn build",
"start": "yarn build && node bin/index.js",
"start": "yarn build && node bin/src/index.js",
"start:dev": "nodemon",

@@ -49,0 +49,0 @@ "build": "rimraf ./bin && tsc",

@@ -43,2 +43,18 @@ # Data Structures

- [print](#print)
- [Doubly Linked List](#doubly-linked-list)
- [Initializer](#initializer)
- [Methods](#methods)
- [insertToHead](#inserttohead)
- [insertToTail](#inserttotail)
- [insertAtPosition](#insertatposition)
- [deleteFromHead](#deletefromhead)
- [deleteFromTail](#deletefromtail)
- [deleteFirstFound](#deletefirstfound)
- [deleteAllFound](#deleteallfound)
- [displayForward](#displayforward)
- [displayBackward](#displaybackward)
- [search](#search)
- [fromArray](#fromarray)
- [getLength](#getlength)
- [isEmpty](#isempty)
- [Queue](#queue)

@@ -285,3 +301,3 @@ - [Initializer](#initializer)

Console log the Linked List elements.
Display the Linked List elements.

@@ -426,2 +442,191 @@ ### Sorted List

### Doubly Linked List
Creates a Doubly Linked List, a data structure where each element is a separate object and the elements linked using pointers to the next and the previous node.
<img src="https://github.com/samaronybarros/data-structures/blob/develop/docs/doubly-linked-list.png?raw=true"
alt="Doubly Linked List"
style="float: left; margin-right: 10px;" />
#### Initializer
```typescript
import { DoublyLinkedList } from 'sb-js-data-structures'
const list = new DoublyLinkedList()
```
#### Methods
##### insertToHead
```typescript
public insertToHead(element: T): void
```
###### Parameters
- **element** `T` - The element to be inserted
###### Description
Inserts an element in the beginning of the Doubly Linked List.
##### insertToTail
```typescript
public insertToTail(element: T): void
```
###### Parameters
- **element** `T` - The element to be inserted
###### Description
Inserts an element in the ending of the Doubly Linked List.
##### insertAtPosition
```typescript
public insertAtPosition(element: T, position: number): void
```
###### Parameters
- **element** `T` - The element to be inserted
- **position** `number` - position where the element should be inserted
###### Description
Inserts an element in a specific position of the Doubly Linked List, since `position` is less than the number of elements of the Doubly Linked List.
##### deleteFromHead
```typescript
public deleteFromHead(): void
```
###### Description
Deletes an element in the beginning of the Doubly Linked List.
##### deleteFromTail
```typescript
public deleteFromTail(): void
```
###### Description
Deletes an element in the ending of the Doubly Linked List.
##### deleteFirstFound
```typescript
public deleteFirstFound(element: T): void
```
###### Parameters
- **element** `T` - The element to be deleted
###### Description
Deletes the `element` found in the Doubly Linked List.
##### deleteAllFound
```typescript
public deleteAllFound(element: T): void
```
###### Parameters
- **element** `T` - The element to be deleted
###### Description
Deletes all the `element`s found in the Doubly Linked List.
##### displayForward
```typescript
public displayForward(): void
```
###### Description
Displays all elements in the Doubly Linked List from the **first** to the **last** element.
##### displayBackward
```typescript
public displayBackward(): void
```
###### Description
Displays all elements in the Doubly Linked List from the **last** to the **first** element.
##### search
```typescript
public search(element: T): number
```
###### Parameters
- **element** `T` - The element to be searched
###### Returns
- **number** - returns the position found or -1 if the element doesn't exist on the list.
###### Description
Searches the `element` in the Doubly Linked List.
##### fromArray
```typescript
public fromArray(element: T[]): void
```
###### Parameters
- **elements** `T[]` - Array of elements
###### Description
Inserts all the `elements` at the ending of the Doubly Linked List.
##### getLength
```typescript
public getLength(): number
```
###### Returns
- **number** - Doubly Linked List length.
###### Description
Gets the length of the Doubly Linked List.
##### isEmpty
```typescript
public isEmpty(): boolean
```
###### Returns
- **boolean** - Returns `true` if the Doubly Linked List has no elements, otherwise, returns `false`.
###### Description
Informs if the Doubly Linked List is empty.
### Queue

@@ -428,0 +633,0 @@

@@ -40,3 +40,3 @@ import { List, NodeOrNull } from './list'

if (position > this.length) {
if (position > this.length || position < 0) {
return

@@ -43,0 +43,0 @@ }

@@ -20,3 +20,3 @@ export interface INode<T> {

public search = (element) => {
public search = (element: T) => {
let list = this.head

@@ -23,0 +23,0 @@ if (list !== null) {

export { BinarySearchTree } from './core/binary-search-tree'
export { DoublyLinkedList } from './core/doubly-linked-list'
export { HashTable } from './core/hash-table'

@@ -3,0 +4,0 @@ export { LinkedList } from './core/linked-list'

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