List

List

여러개의 자료를 하나의 변수로 관리할 때 사용하는 자료구조이다.

Constructor

new List()

Author:
  • yicho93@gmail.com
Example
var l = new List ();

Methods

(static) append(value)

This method is used to append value at the end of list.
Example
var l = new List ();
l.append(1);
l.append(2);
l.append(3);
Parameters:
Name Type Description
value undefined The element to be appended to this linked list.

(static) clear()

This method is used to nullify this list and make all variables initial.
Example
var l = new List ();
l.append(1);
l.append(2);
l.append(3);
l.clear();

(static) contains(value) → {Boolean}

This method is used to check if this list contains the specified value.
Example
var l = new List ();
l.append(1);
l.append(2);
l.append(3);
var ret1 = l.contains(2); // ret1 = true
var ret2 = l.contains(4); // ret2 = false
Parameters:
Name Type Description
value undefined The value to be checked from this list.
Returns:
This method returns ‘true’ if the specified value is exist in this list, or ‘false’ if the specified value isn't exist in this list
Type
Boolean

(static) end()

This method is used to make positon to end in this list.
Example
var l = new List ();
l.append(1);
l.append(2);
l.end();

(static) find(value) → {Number}

This method is used to find position of value in this list
Example
var l = new List ();
var ret1 = l.find(1); // ret1 = -1
l.append(1);
l.append(2);
var ret2 = l.find(1); // ret2 = 0
Parameters:
Name Type Description
value undefined The value which want to get position from list.
Throws:
This method returns null if this list doesn't have specified value.
Returns:
This method returns position of value if this list has specified value.
Type
Number

(static) front()

This method is used to make positon to front in this list.
Example
var l = new List ();
l.append(1);
l.append(2);
l.front();

(static) get(position) → {undefined}

This method is used to get value of specifed position in this list.
Example
var l = new List ();
l.append(1);
l.append(2);
l.append(3);
var ret = l.get(1);  // ret = 2
Parameters:
Name Type Description
position Number The position which want to get value from this list.
Throws:
This method returns null if this position of list doesn't have value.
Returns:
This method returns the value from the specified position from this list.
Type
undefined

(static) getElement() → {undefined}

This method is used to get value in this list, but does not remove.
Example
var l = new List ();
l.append(1);
l.append(2);
l.append(3);
l.append(4);
var ret = l.getElement();  // return 4, if current posion is 3.
Returns:
This method returns the value of current position in this list.
Type
undefined

(static) insert(position, value)

This method is used to position specified value at the specifed position in this list.
Example
var l = new List ();
l.append(1);
l.append(2);
l.append(3);
Parameters:
Name Type Description
position Number The position to be appended to this list.
value undefined The value to be appended to this list.

(static) moveTo(position)

This method is used to set position in this list
Example
var l = new List ();
l.append(1);
l.append(2);
l.append(3);
l.append(4);
var ret = l.moveTo(2);
Parameters:
Name Type Description
position Number The position which want to set in this list.

(static) next()

This method is used to make positon to next of this list.
Example
var l = new List ();
l.append(1);
l.append(2);
l.next();

(static) prev()

This method is used to make positon to previous of this list.
Example
var l = new List ();
l.append(1);
l.append(2);
l.prev();

(static) prev() → {Number}

This method is used to get current position in this list.
Example
var l = new List ();
l.append(1);
l.append(2);
var ret = l.currPos();
Returns:
This method returns current position in this list.
Type
Number

(static) remove(value) → {Boolean}

This method is used to remove the value from this list.
Example
var l = new List ();
l.append(1);
l.append(2);
l.append(3);
var ret1 = l.remove(3); // ret1 = true
var ret2 = l.remove(4); // ret2 = false
Parameters:
Name Type Description
value undefined The value to be removed from this list.
Returns:
This method returns ‘true’ if this list remove the specified value or ‘false’ if the list doesn't remove the specified value
Type
Boolean

(static) size() → {Number}

This method is used to get the number of value in this list.
Example
var l = new size ();
l.append(1);
l.append(2);
l.append(3);
var size = ll.size(); // ret = 3
Returns:
This method returns the number of value in this list.
Type
Number

(static) toString() → {String}

This method is used to get values of this list.
Example
var l = new List ();
l.append(1);
l.append(2);
l.append(3);
var v = l.toString(); // v = 1,2, 3
Returns:
This method returns the String which has value of this list.
Type
String