Cheatography
https://cheatography.com
List
Creation
const list = new List();
Adding Element
list.add(3);
list.addAtHead(0);
Removing Element
list.remove(4);
Setting Value
list.set(1, 127);
Checking if a value is included
list.contains(1);
Looping
for(let i = 0; i < list.size(); i++){
console.log(list.get(i));
});
|
Array
Declaration and inizialitation
let array = ['dog', 'cat', 'bird'];
let also = new Array(5);
`
Adding Element
array[3] = 'statistics';
Setting Value
array[3] = 'whale';
Deleting Element
delete array[4];
Looping
array.forEach({...});
Checking if a value is included
array.includes('dog');
|
|
|
LinkedList
Creation
let linkedList = new LinkedList();
Adding an element
linkedList.append(2);
linkedList.prepend(6);
linkedList.addAt(2, 5);
Fetch of the head value
linkedList.fetchHead();
Get the value of a specific index
linkedList.getAt(5);
Removing an element
linkedList.removeAt(4);
linkedList.delete(9);
Check if a value is included
linkedList.contains(4);
Looping
for (const e of linkedList) {...}
|
SortedSet
Creation
let sortedSet = new SortedSet();
Adding an element
sortedSet.add(5);
Removing an element
sortedSet.delete(2);
Checking if an element is included
sortedSet.has(3);
Looping
for(element in sortedSet.toArray) {
console.log(element);
});
|
|
|
Dictionary
Creation
let dict = new Dictionary();
Adding a pair
dict.add('age', 18);
Setting a value
dict.set('height', 183);
Removing a key
dict.remove('height');
Checking if a key is included
dict.hasKey('fage');
Checking if a value is included
dict.hasValue(18);
|
HashSet
Creation
let hashset = new HashSet();
Adding Element
hashset.add(3);
Removing Element
hashset.delete(2);
Checking if an element is included
hashset.has(3);
Looping
let keys = hashset.values();
for(let i = 0; i < keys.length; i++){
console.log(keys[i]);
});
|
|
Created By
Metadata
Comments
No comments yet. Add yours below!
Add a Comment