Methods
allIndexesOfK(tl, k) → {Array}
allIndexesOfK
Parameters:
| Name | Type | Description |
|---|---|---|
tl |
Array | tlist |
k |
String | Number | key |
Returns:
indexes - indexes
- Type
- Array
Example
term
//prototype
var tl = new Tlist([ 0,'a' ], [ 1,'b' ],[2,'c'], [ 0,'a' ], [ 1,'b' ],[2,'c'])
tl.allIndexesOfK(0)
tl[0]
tl[3]
////
> tl.allIndexesOfK(0)
[ 0, 3 ]
> tl[0]
[ 0, 'a' ]
> tl[3]
[ 0, 'a' ]
//function
var tl = [ [ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 0, 'a' ], [ 1, 'b' ],[2,'c'] ]
tlist.allIndexesOfK(tl,0)
////
> tlist.allIndexesOfK(tl,0)
[ 0, 3 ]
allIndexesOfKV(tl, k, v) → {Array}
allIndexesOfKV
Parameters:
| Name | Type | Description |
|---|---|---|
tl |
Array | tlist |
k |
String | Number | key |
v |
String | Number | value |
Returns:
indexes - indexes
- Type
- Array
Example
term
//prototype
var tl = new Tlist([ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 0, 'a' ], [ 1, 'b' ],[2,'c'])
tl.allIndexesOfKV(2,'c')
tl[2]
tl[5]
////
> tl.allIndexesOfKV(2,'c')
[ 2, 5 ]
> tl[2]
[ 2, 'c' ]
> tl[5]
[ 2, 'c' ]
//function
var tl = [ [ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 0, 'a' ], [ 1, 'b' ],[2,'c'] ]
tlist.allIndexesOfKV(tl,0,'a')
////
>tlist.allIndexesOfKV(tl,0,'a')
[0,3]
allIndexesOfV(tl, v) → {Array}
allIndexesOfV
Parameters:
| Name | Type | Description |
|---|---|---|
tl |
Array | tlist |
v |
String | Number | value |
Returns:
indexes - indexes
- Type
- Array
Example
term
//prototype
var tl = new Tlist([ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 0, 'a' ], [ 1, 'b' ],[2,'c'])
tl.allIndexesOfV('b')
tl[1]
tl[4]
////
> tl.allIndexesOfV('b')
[ 1, 4 ]
> tl[1]
[ 1, 'b' ]
> tl[4]
[ 1, 'b' ]
//function
var tl = [ [ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 0, 'a' ], [ 1, 'b' ],[2,'c'] ]
tlist.allIndexesOfV(tl,'b')
////
> tlist.allIndexesOfV(tl,'b')
[ 1, 4 ]
append(tl, k, v) → {Array}
append
Parameters:
| Name | Type | Description |
|---|---|---|
tl |
Array | tlist |
k |
String | Number | key |
v |
String | Number | value |
Returns:
tl - tlist
- Type
- Array
Example
term
//prototype
var tl = new Tlist([ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 0, 'a' ], [ 1, 'b' ],[2,'c'])
tl.append('k','v')
////
> tl.append('k','v')
Tlist [
[ 0, 'a' ],
[ 1, 'b' ],
[ 2, 'c' ],
[ 0, 'a' ],
[ 1, 'b' ],
[ 2, 'c' ],
[ 'k', 'v' ]]
>
//function
var tl = [ [ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 0, 'a' ], [ 1, 'b' ],[2,'c'] ]
tlist.append(tl,'k','v')
////
> tlist.append(tl,'k','v')
[ [ 0, 'a' ],
[ 1, 'b' ],
[ 2, 'c' ],
[ 0, 'a' ],
[ 1, 'b' ],
[ 2, 'c' ],
[ 'k', 'v' ]]
countK(tl, k) → {Number}
countK
Parameters:
| Name | Type | Description |
|---|---|---|
tl |
Array | tlist |
k |
String | Number | key |
Returns:
count - count
- Type
- Number
Example
term
//prototype
var tl = new Tlist([ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 0, 'a' ], [ 1, 'b' ],[2,'c'])
tl.countK(1)
////
2
//function
var tl = [ [ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 0, 'a' ], [ 1, 'b' ],[2,'c'] ]
tlist.countK(tl,1)
////
2
countKV(tl, k, v) → {Number}
countKV
Parameters:
| Name | Type | Description |
|---|---|---|
tl |
Array | tlist |
k |
String | Number | key |
v |
String | Number | value |
Returns:
count - count
- Type
- Number
Example
term
//prototype
var tl = new Tlist([ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 0, 'a' ], [ 1, 'b' ],[2,'c'])
tl.countKV(2,'c')
////
2
//function
var tl = [ [ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 0, 'a' ], [ 1, 'b' ],[2,'c'] ]
tlist.countKV(tl,2,'c')
////
> tlist.countKV(tl,2,'c')
2
countV(tl, v) → {Number}
countV
Parameters:
| Name | Type | Description |
|---|---|---|
tl |
Array | tlist |
v |
String | Number | value |
Returns:
count - count
- Type
- Number
Example
term
//prototype
var tl = new Tlist([ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 0, 'a' ], [ 1, 'b' ],[2,'c'])
tl.countV('c')
////
2
//function
var tl = [ [ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 0, 'a' ], [ 1, 'b' ],[2,'c'] ]
tlist.countV(tl,'c')
////
> tlist.countV(tl,'c')
2
d2t(d) → {Array}
d2t
Parameters:
| Name | Type | Description |
|---|---|---|
d |
Object | dict |
Returns:
t - tuple
- Type
- Array
Example
term
//prototype
////
//function
tlist.d2t({ a: 1 })
////
> tlist.d2t({ a: 1 })
[ 'a', 1 ]
d2tl(d) → {Array}
d2tl
Parameters:
| Name | Type | Description |
|---|---|---|
d |
Object | dict |
Returns:
tl - [t0,t1,...tk...,tn]
- Type
- Array
Example
term
//prototype
////
//function
var d = { '0': 'b', '1': 'b' }
tlist.d2tl(d)
////
> tlist.d2tl(d)
[ [ '0', 'b' ], [ '1', 'b' ] ]
deepcopy() → {Array|Array}
deepcopy
Returns:
-
tl - [t0,t1,...tk...,tn]
- Type
- Array
-
ntl - new tlist
- Type
- Array
Example
term
var tlist = require("tlist")
//prototype
var tl=new Tlist([ [ 0, 'a' ], [ 1, 'b' ], [ 2, 'a' ], [ 3, 'b' ] ])
tl.deepcopy()
////
//function
var tl = [ [ 0, 'a' ], [ 1, 'b' ], [ 2, 'a' ], [ 3, 'b' ] ]
tlist.deepcopy(tl)
////
> tlist.deepcopy(tl)
[ [ 0, 'a' ], [ 1, 'b' ], [ 2, 'a' ], [ 3, 'b' ] ]
extend(tl0, tl1) → {Array}
extend
Parameters:
| Name | Type | Description |
|---|---|---|
tl0 |
Array | tlist |
tl1 |
Array | tlist |
Returns:
tl - [t0,t1,...tk...,tn]
- Type
- Array
Example
term
//prototype
var tl0 = new Tlist([ 0, 'a' ], [ 0, 'b' ])
var tl1 = new Tlist([ 1, 'a' ], [ 1, 'b' ])
tl0.extend(tl1)
////
Tlist [ [ 0, 'a' ], [ 0, 'b' ], [ 1, 'a' ], [ 1, 'b' ] ]
//function
var tl0 = [ [ 0, 'a' ], [ 0, 'b' ] ]
var tl1 = [ [ 1, 'a' ], [ 1, 'b' ] ]
tlist.extend(tl0,tl1)
////
> tlist.extend(tl0,tl1)
[ [ 0, 'a' ], [ 0, 'b' ], [ 1, 'a' ], [ 1, 'b' ] ]
firstIndexOfK(tl, k) → {Number}
firstIndexOfK
Parameters:
| Name | Type | Description |
|---|---|---|
tl |
Array | tlist |
k |
String | Number | key |
Returns:
index - index
- Type
- Number
Example
term
//prototype
var tl = new Tlist([ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 0, 'a' ], [ 1, 'b' ],[2,'c'])
tl.firstIndexOfK(1)
////
1
//function
var tl = [ [ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 0, 'a' ], [ 1, 'b' ],[2,'c'] ]
tlist.firstIndexOfK(tl,0)
////
> tlist.firstIndexOfK(tl,0)
0
firstIndexOfKV(tl, k, v) → {Number}
firstIndexOfKV
Parameters:
| Name | Type | Description |
|---|---|---|
tl |
Array | tlist |
k |
String | Number | key |
v |
String | Number | value |
Returns:
index - index
- Type
- Number
Example
term
//prototype
var tl = new Tlist([ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 0, 'a' ], [ 1, 'b' ],[2,'c'])
tl.firstIndexOfKV(2,'c')
////
2
//function
var tl = [ [ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 0, 'a' ], [ 1, 'b' ],[2,'c'] ]
tlist.firstIndexOfKV(tl,2,'c')
////
> tlist.firstIndexOfKV(tl,2,'c')
2
firstIndexOfV(tl, v) → {Number}
firstIndexOfV
Parameters:
| Name | Type | Description |
|---|---|---|
tl |
Array | tlist |
v |
String | Number | value |
Returns:
index - index
- Type
- Number
Example
term
//prototype
var tl = new Tlist([ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 0, 'a' ], [ 1, 'b' ],[2,'c'])
tl.firstIndexOfV('b')
////
1
//function
var tl = [ [ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 0, 'a' ], [ 1, 'b' ],[2,'c'] ]
firstIndexOfV(tl,'b')
////
1
getAllK(tl, k) → {Array}
getAllK
Parameters:
| Name | Type | Description |
|---|---|---|
tl |
Array | tlist |
k |
String | Number | key |
Returns:
tl - [t0,t1,...tk...,tn]
- Type
- Array
Example
term
//prototype
var tl = new Tlist([ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 3, 'a' ], [ 1, 'b' ],[2,'d'])
tl.getAllK(2)
////
Tlist [ [ 2, 'c' ], [ 2, 'd' ] ]
//function
var tl = [ [ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 3, 'a' ], [ 1, 'b' ],[2,'d'] ]
tlist.getAllK(tl,2)
////
[ [ 2, 'c' ], [ 2, 'd' ] ]
getAllKV(tl, k, v) → {Array}
getAllKV
Parameters:
| Name | Type | Description |
|---|---|---|
tl |
Array | tlist |
k |
String | Number | key |
v |
String | Number | value |
Returns:
tl - [t0,t1,...tk...,tn]
- Type
- Array
Example
term
//prototype
var tl = new Tlist([ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 3, 'a' ], [ 1, 'b' ],[2,'d'])
tlist.getAllKV(1,'b')
////
[ [ 1, 'b' ], [ 1, 'b' ] ]
//function
var tl = [ [ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 3, 'a' ], [ 1, 'b' ],[2,'c'] ]
tlist.getAllKV(tl,1,'b')
////
[ [ 1, 'b' ], [ 1, 'b' ] ]
getAllV(tl, v) → {Array}
getAllV
Parameters:
| Name | Type | Description |
|---|---|---|
tl |
Array | tlist |
v |
String | Number | value |
Returns:
tl - [t0,t1,...tk...,tn]
- Type
- Array
Example
term
//prototype
var tl = new Tlist([ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 3, 'a' ], [ 1, 'b' ],[2,'d'])
tl.getAllV('a')
////
Tlist [ [ 0, 'a' ], [ 3, 'a' ] ]
//function
var tl = [ [ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 3, 'a' ], [ 11, 'b' ],[2,'c'] ]
tlist.getAllV(tl,'a')
////
[ [ 0, 'a' ], [ 3, 'a' ] ]
getFirstK(tl, k) → {Array}
getFirstK
Parameters:
| Name | Type | Description |
|---|---|---|
tl |
Array | tlist |
k |
String | Number | key |
Returns:
tl - [t0,t1,...tk...,tn]
- Type
- Array
Example
term
//prototype
var tl = new Tlist([ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 3, 'a' ], [ 1, 'b' ],[2,'d'])
tl.getFirstK(2)
////
[ 2, 'c' ]
//function
var tl = [ [ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 3, 'a' ], [ 1, 'b' ],[2,'d'] ]
tlist.getFirstK(tl,2)
////
[ 2, 'c']
getFirstKV(tl, k, v) → {Array}
getFirstKV
Parameters:
| Name | Type | Description |
|---|---|---|
tl |
Array | tlist |
k |
String | Number | key |
v |
String | Number | value |
Returns:
tl - [t0,t1,...tk...,tn]
- Type
- Array
Example
term
//prototype
var tl = new Tlist([ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 3, 'a' ], [ 1, 'b' ],[2,'c'])
tl.getFirstKV(0,'a')
////
[ 0, 'a' ]
//function
var tl = [ [ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 3, 'a' ], [ 1, 'b' ],[2,'c'] ]
tlist.getFirstKV(tl,0,'a')
////
[ 0, 'a' ]
getFirstV(tl, v) → {Array}
getFirstV
Parameters:
| Name | Type | Description |
|---|---|---|
tl |
Array | tlist |
v |
String | Number | value |
Returns:
tl - [t0,t1,...tk...,tn]
- Type
- Array
Example
term
//prototype
var tl = new Tlist([ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 3, 'a' ], [ 1, 'b' ],[2,'d'])
tl.getFirstV('a')
////
[ 0, 'a' ]
//function
var tl = [ [ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 3, 'a' ], [ 1, 'b' ],[2,'c'] ]
tlist.getFirstV(tl,'a')
////
[ 0, 'a' ]
getK(tl, k, which) → {Array}
getK
Parameters:
| Name | Type | Description |
|---|---|---|
tl |
Array | tlist |
k |
String | Number | key |
which |
Number | index |
Returns:
tl - [t0,t1,...tk...,tn]
- Type
- Array
Example
term
//prototype
var tl = new Tlist([ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 3, 'a' ], [ 11, 'b' ],[2,'d'])
tl.getK(2,0)
tl.getK(2,1)
////
> tl.getK(2,0)
[ 2, 'c' ]
> tl.getK(2,1)
[ 2, 'd' ]
//function
var tl = [ [ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 3, 'a' ], [ 11, 'b' ],[2,'d'] ]
tlist.getK(tl,2,1)
////
[ 2, 'd']
getKV(tl, k, v, which) → {Array}
getKV
Parameters:
| Name | Type | Description |
|---|---|---|
tl |
Array | tlist |
k |
String | Number | key |
v |
String | Number | value |
which |
Number | index |
Returns:
tl - [t0,t1,...tk...,tn]
- Type
- Array
Example
term
//prototype
var tl = new Tlist([ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 3, 'a' ], [ 1, 'b' ],[2,'c'])
tl.getKV(tl,1,'b',1)
////
> tl.getKV(1,'b',0)
[ 1, 'b' ]
//function
var tl = [ [ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 3, 'a' ], [ 1, 'b' ],[2,'c'] ]
tlist.getKV(tl,1,'b',1)
////
[ 1, 'b' ]
getLastK(tl, k) → {Array}
getLastK
Parameters:
| Name | Type | Description |
|---|---|---|
tl |
Array | tlist |
k |
String | Number | key |
Returns:
tl - [t0,t1,...tk...,tn]
- Type
- Array
Example
term
//prototype
var tl = new Tlist([ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 3, 'a' ], [ 1, 'b' ],[2,'d'])
tl.getLastK(2)
////
[ 2, 'd' ]
//function
var tl = [ [ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 3, 'a' ], [ 1, 'b' ],[2,'d'] ]
tlist.getLastK(tl,2)
////
[ 2, 'd' ]
getLastKV(tl, k, v) → {Array}
getLastKV
Parameters:
| Name | Type | Description |
|---|---|---|
tl |
Array | tlist |
k |
String | Number | key |
v |
String | Number | value |
Returns:
tl - [t0,t1,...tk...,tn]
- Type
- Array
Example
term
//prototype
var tl = new Tlist([ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 3, 'a' ], [ 1, 'b' ],[2,'d'])
tl.getLastKV(2,'c')
////
[ 2, 'c']
//function
var tl = [ [ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 3, 'a' ], [ 1, 'b' ],[2,'c'] ]
tlist.getLastKV(tl,2,'c')
////
[ 2, 'c' ]
getLastV(tl, v) → {Array}
getLastV
Parameters:
| Name | Type | Description |
|---|---|---|
tl |
Array | tlist |
v |
String | Number | value |
Returns:
tl - [t0,t1,...tk...,tn]
- Type
- Array
Example
term
//prototype
var tl = new Tlist([ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 3, 'a' ], [ 1, 'b' ],[2,'d'])
tl.getLastV('a')
////
[ 3, 'a' ]
//function
var tl = [ [ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 3, 'a' ], [ 1, 'b' ],[2,'d'] ]
tlist.getLastV(tl,'a')
////
[ 3, 'a' ]
getV(tl, v, which) → {Array}
getV
Parameters:
| Name | Type | Description |
|---|---|---|
tl |
Array | tlist |
v |
String | Number | value |
which |
Number | index |
Returns:
tl - [t0,t1,...tk...,tn]
- Type
- Array
Example
term
//prototype
var tl = new Tlist([ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 3, 'a' ], [ 11, 'b' ],[2,'d'])
tl.getV('b',0)
tl.getV('b',1)
////
> tl.getV('b',0)
[ 1, 'b' ]
> tl.getV('b',1)
[ 11, 'b' ]
//function
var tl = [ [ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 3, 'a' ], [ 11, 'b' ],[2,'d'] ]
tlist.getV(tl,'b',1)
////
[ 11, 'b' ]
includesK(tl, k) → {Boolean}
includesK
Parameters:
| Name | Type | Description |
|---|---|---|
tl |
Array | tlist |
k |
String | Number | key |
Returns:
rslt - rslt
- Type
- Boolean
Example
term
//prototype
var tl = new Tlist([ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 0, 'a' ], [ 1, 'b' ],[2,'c'])
tl.includesK(1)
tl.includesK(200)
////
> tl.includesK(1)
true
> tl.includesK(200)
false
//function
var tl = [ [ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 0, 'a' ], [ 1, 'b' ],[2,'c'] ]
tlist.includesK(tl,1)
tlist.includesK(tl,200)
////
> tlist.includesK(tl,1)
true
> tlist.includesK(tl,200)
false
includesKV(tl, k, v) → {Boolean}
includesKV
Parameters:
| Name | Type | Description |
|---|---|---|
tl |
Array | tlist |
k |
String | Number | key |
v |
String | Number | value |
Returns:
rslt - rslt
- Type
- Boolean
Example
term
//prototype
var tl = new Tlist([ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 0, 'a' ], [ 1, 'b' ],[2,'c'])
tl.includesKV(0,'a')
tl.includesKV(0,'c')
////
>tl.includesKV(0,'a')
true
>tl.includesKV(0,'c')
false
//function
var tl = [ [ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 0, 'a' ], [ 1, 'b' ],[2,'c'] ]
tlist.includesKV(tl,0,'a')
tlist.includesKV(tl,0,'c')
////
> tlist.includesKV(tl,0,'a')
true
> tlist.includesKV(tl,0,'c')
false
includesV(tl, v) → {Boolean}
includesV
Parameters:
| Name | Type | Description |
|---|---|---|
tl |
Array | tlist |
v |
String | Number | value |
Returns:
rslt - rslt
- Type
- Boolean
Example
term
//prototype
var tl = new Tlist([ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 0, 'a' ], [ 1, 'b' ],[2,'c'])
tl.includesV('b')
tl.includesV('e')
////
>tl.includesV('b')
true
>tl.includesV('e')
false
//function
var tl = [ [ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 0, 'a' ], [ 1, 'b' ],[2,'c'] ]
tlist.includesV(tl,'b')
tlist.includesV(tl,'e')
////
> tlist.includesV(tl,'b')
true
> tlist.includesV(tl,'e')
false
insert(tl, k, v, position) → {Array}
insert
Parameters:
| Name | Type | Description |
|---|---|---|
tl |
Array | tlist |
k |
String | Number | key |
v |
String | Number | value |
position |
Number | index |
Returns:
tl - tlist
- Type
- Array
Example
term
//prototype
//to avoid name conflict with prototype insert added by elist to Array
//insertOne
var tl = new Tlist([ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 0, 'a' ], [ 1, 'b' ],[2,'c'])
tl.insertOne('k','v',2)
////
> tl.insertOne('k','v',2)
Tlist [
[ 0, 'a' ],
[ 1, 'b' ],
[ 'k', 'v' ],
[ 2, 'c' ],
[ 0, 'a' ],
[ 1, 'b' ],
[ 2, 'c' ] ]
>
//function
var tl = [ [ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 0, 'a' ], [ 1, 'b' ],[2,'c'] ]
tlist.insert(tl,'k','v',2)
////
> tlist.insert(tl,'k','v',2)
[ [ 0, 'a' ],
[ 1, 'b' ],
[ 'k', 'v' ],
[ 2, 'c' ],
[ 0, 'a' ],
[ 1, 'b' ],
[ 2, 'c' ] ]
insertTl(tl, tl1, position) → {Array}
insertTl
Parameters:
| Name | Type | Description |
|---|---|---|
tl |
Array | tlist |
tl1 |
Array | tlist |
position |
Number | index |
Returns:
tl - [t0,t1,...tk...,tn]
- Type
- Array
Example
term
//prototype
var tl = new Tlist([ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 0, 'a' ], [ 1, 'b' ],[2,'c'])
var tl1 = new Tlist(['k','v'],['k','v'])
tl.insertTl(tl1,2)
////
> tl.insertTl(tl1,2)
Tlist [
[ 0, 'a' ],
[ 1, 'b' ],
[ 'k', 'v' ],
[ 'k', 'v' ],
[ 2, 'c' ],
[ 0, 'a' ],
[ 1, 'b' ],
[ 2, 'c' ] ]
>
//function
var tl = [ [ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 0, 'a' ], [ 1, 'b' ],[2,'c'] ]
var tl1 = [ ['k','v'],['k','v']]
tlist.insertTl(tl,tl1,2)
tl
////
> tlist.insertTl(tl,tl1,2)
[ [ 0, 'a' ],
[ 1, 'b' ],
[ 'k', 'v' ],
[ 'k', 'v' ],
[ 2, 'c' ],
[ 0, 'a' ],
[ 1, 'b' ],
[ 2, 'c' ] ]
> tl1
[ [ 'k', 'v' ], [ 'k', 'v' ] ]
>
> tl
[ [ 0, 'a' ],
[ 1, 'b' ],
[ 2, 'c' ],
[ 0, 'a' ],
[ 1, 'b' ],
[ 2, 'c' ] ]
>
isTlist(obj) → {Boolean}
isTlist
Parameters:
| Name | Type | Description |
|---|---|---|
obj |
Object | object |
Returns:
rslt - rslt
- Type
- Boolean
Example
term
var tlist = require("tlist")
//prototype
////
//function
tlist.isTlist(tl)
var tl = [['a',0] ,'b',['a',2]]
tlist.isTlist(tl)
////
> var tl = [['a',0] ,['b',1],['a',2]]
undefined
> tlist.isTlist(tl)
true
> var tl = [['a',0] ,'b',['a',2]]
undefined
> tlist.isTlist(tl)
false
>
isTuple(obj) → {Boolean}
isTuple
Parameters:
| Name | Type | Description |
|---|---|---|
obj |
Object | object |
Returns:
rslt - rslt
- Type
- Boolean
Example
term
var tlist = require("tlist")
//prototype
////
//function
var t = ['a',0]
tlist.isTuple(t)
var t = ['a']
tlist.isTuple(t)
var t = ['a',0,'b']
tlist.isTuple(t)
////
> var t = ['a',0]
undefined
> tlist.isTuple(t)
true
> var t = ['a']
undefined
> tlist.isTuple(t)
false
> var t = ['a',0,'b']
undefined
> tlist.isTuple(t)
false
>
kvl2tl(kl, vl) → {Array}
kvl2tl
Parameters:
| Name | Type | Description |
|---|---|---|
kl |
Array | key list |
vl |
Array | value list |
Returns:
tl - [t0,t1,...tk...,tn]
- Type
- Array
Example
term
var tlist = require("tlist")
//prototype
////
//function
var kl =[0,1,2,3]
var vl =['a','b','a','b']
tlist.kvl2tl(kl,vl)
////
> tlist.kvl2tl(kl,vl)
[ [ 0, 'a' ], [ 1, 'b' ], [ 2, 'a' ], [ 3, 'b' ] ]
l2tl(l) → {Array}
l2tl
Parameters:
| Name | Type | Description |
|---|---|---|
l |
Array | list |
Returns:
tl - [t0,t1,...tk...,tn]
- Type
- Array
Example
term
//prototype
////
//function
var l = [ 0, 'a', 1, 'b', 2, 'c', 0, 'a', 1, 'b', 2, 'c' ]
tlist.l2tl(l)
////
> tlist.l2tl(l)
[ [ 0, 'a' ],
[ 1, 'b' ],
[ 2, 'c' ],
[ 0, 'a' ],
[ 1, 'b' ],
[ 2, 'c' ] ]
>
lastIndexOfK(tl, k) → {Number}
lastIndexOfK
Parameters:
| Name | Type | Description |
|---|---|---|
tl |
Array | tlist |
k |
String | Number | key |
Returns:
index - index
- Type
- Number
Example
term
//prototype
var tl = new Tlist([ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 0, 'a' ], [ 1, 'b' ],[2,'c'])
tl.lastIndexOfK(0)
////
3
//function
var tl = [ [ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 0, 'a' ], [ 1, 'b' ],[2,'c'] ]
tlist.lastIndexOfK(tl,0)
////
> tlist.lastIndexOfK(tl,0)
3
lastIndexOfKV(tl, k, v) → {Number}
lastIndexOfKV
Parameters:
| Name | Type | Description |
|---|---|---|
tl |
Array | tlist |
k |
String | Number | key |
v |
String | Number | value |
Returns:
index - index
- Type
- Number
Example
term
//prototype
var tl = new Tlist([ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 0, 'a' ], [ 1, 'b' ],[2,'c'])
tl.lastIndexOfKV(2,'c')
////
5
//function
var tl = [ [ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 0, 'a' ], [ 1, 'b' ],[2,'c'] ]
tlist.lastIndexOfKV(tl,2,'c')
////
5
lastIndexOfV(tl, v) → {Array}
lastIndexOfV
Parameters:
| Name | Type | Description |
|---|---|---|
tl |
Array | tlist |
v |
String | Number | value |
Returns:
tl - [t0,t1,...tk...,tn]
- Type
- Array
Example
term
//prototype
var tl = new Tlist([ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 0, 'a' ], [ 1, 'b' ],[2,'c'])
tl.lastIndexOfV('b')
////
4
//function
var tl = [ [ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 0, 'a' ], [ 1, 'b' ],[2,'c'] ]
tlist.lastIndexOfV(tl,'b')
////
4
prepend(tl, k, v) → {Array}
prepend
Parameters:
| Name | Type | Description |
|---|---|---|
tl |
Array | tlist |
k |
String | Number | key |
v |
String | Number | value |
Returns:
tl - tlist
- Type
- Array
Example
term
//prototype
var tl = new Tlist([ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 0, 'a' ], [ 1, 'b' ],[2,'c'])
tl.prepend('k','v')
////
> tl.prepend('k','v')
Tlist [
['k', 'v'],
[ 0, 'a' ],
[ 1, 'b' ],
[ 2, 'c' ],
[ 0, 'a' ],
[ 1, 'b' ],
[ 2, 'c' ]]
>
//function
var tl = [ [ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 0, 'a' ], [ 1, 'b' ],[2,'c'] ]
tlist.prepend(tl,'k','v')
////
> tlist.prepend(tl,'k','v')
[
['k', 'v'],
[ 0, 'a' ],
[ 1, 'b' ],
[ 2, 'c' ],
[ 0, 'a' ],
[ 1, 'b' ],
[ 2, 'c' ]]
prextend(tl0, tl1) → {Array}
preextend
Parameters:
| Name | Type | Description |
|---|---|---|
tl0 |
Array | tlist |
tl1 |
Array | tlist |
Returns:
tl - [t0,t1,...tk...,tn]
- Type
- Array
Example
term
//prototype
var tl0 = new Tlist([ 0, 'a' ], [ 0, 'b' ])
var tl1 = new Tlist([ 1, 'a' ], [ 1, 'b' ])
tl0.prextend(tl1)
////
Tlist [ [ 1, 'a' ], [ 1, 'b' ], [ 0, 'a' ], [ 0, 'b' ] ]
//function
var tl0 = [ [ 0, 'a' ], [ 0, 'b' ] ]
var tl1 = [ [ 1, 'a' ], [ 1, 'b' ] ]
tlist.prextend(tl0,tl1)
////
> tlist.prextend(tl0,tl1)
[ [ 1, 'a' ], [ 1, 'b' ], [ 0, 'a' ], [ 0, 'b' ] ]
rmAllK(tl, k) → {Array}
rmAllK
Parameters:
| Name | Type | Description |
|---|---|---|
tl |
Array | tlist |
k |
String | Number | key |
Returns:
tl - [t0,t1,...tk...,tn]
- Type
- Array
Example
term
//prototype
var tl = new Tlist([ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 0, 'a' ], [ 1, 'b' ],[2,'c'])
tl.rmAllK(2)
////
Tlist [ [ 0, 'a' ], [ 1, 'b' ], [ 0, 'a' ], [ 1, 'b' ] ]
//function
var tl = [ [ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 3, 'a' ], [ 1, 'b' ],[2,'c'] ]
tlist.rmAllK(tl,2)
tl
////
[ [ 0, 'a' ], [ 1, 'b' ], [ 3, 'a' ], [ 1, 'b' ] ]
rmAllKV(tl, k, v) → {Array}
rmAllKV
Parameters:
| Name | Type | Description |
|---|---|---|
tl |
Array | tlist |
k |
String | Number | key |
v |
String | Number | value |
Returns:
tl - [t0,t1,...tk...,tn]
- Type
- Array
Example
term
//prototype
var tl = new Tlist([ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 0, 'a' ], [ 1, 'b' ],[2,'c'])
tl.rmAllKV(1,'b')
////
Tlist [ [ 0, 'a' ], [ 2, 'c' ], [ 0, 'a' ], [ 2, 'c' ] ]
//function
var tl = [ [ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 3, 'a' ], [ 1, 'b' ],[2,'c'] ]
tlist.rmAllKV(tl,1,'b')
////
[ [ 0, 'a' ], [ 2, 'c' ], [ 3, 'a' ], [ 2, 'c' ] ]
rmAllV(tl, v) → {Array}
rmAllV
Parameters:
| Name | Type | Description |
|---|---|---|
tl |
Array | tlist |
v |
String | Number | value |
Returns:
tl - [t0,t1,...tk...,tn]
- Type
- Array
Example
term
//prototype
var tl = new Tlist([ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 0, 'a' ], [ 1, 'b' ],[2,'c'])
tl.rmAllV('a')
////
Tlist [ [ 1, 'b' ], [ 2, 'c' ], [ 1, 'b' ], [ 2, 'c' ] ]
//function
var tl = [ [ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 3, 'a' ], [ 1, 'b' ],[2,'c'] ]
tlist.rmAllV(tl,'a')
tl
////
[ [ 1, 'b' ], [ 2, 'c' ], [ 1, 'b' ], [ 2, 'c' ] ]
rmFirstK(tl, k) → {Array}
rmFirstK
Parameters:
| Name | Type | Description |
|---|---|---|
tl |
Array | tlist |
k |
String | Number | key |
Returns:
tl - [t0,t1,...tk...,tn]
- Type
- Array
Example
term
//prototype
var tl = new Tlist([ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 0, 'a' ], [ 1, 'b' ],[2,'c'])
tl.rmFirstK(1)
////
Tlist [ [ 0, 'a' ], [ 2, 'c' ], [ 0, 'a' ], [ 1, 'b' ], [ 2, 'c' ] ]
//function
var tl = [ [ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 3, 'a' ], [ 1, 'b' ],[2,'c'] ]
tlist.rmFirstK(tl,1)
tl
////
[ [ 0, 'a' ], [ 2, 'c' ], [ 3, 'a' ], [ 1, 'b' ], [ 2, 'c' ] ]
rmFirstKV(tl, k, v) → {Array}
rmFirstKV
Parameters:
| Name | Type | Description |
|---|---|---|
tl |
Array | tlist |
k |
String | Number | key |
v |
String | Number | value |
Returns:
tl - [t0,t1,...tk...,tn]
- Type
- Array
Example
term
//prototype
var tl = new Tlist([ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 0, 'a' ], [ 1, 'b' ],[2,'c'])
tl.rmFirstKV(2,'c')
////
Tlist [ [ 0, 'a' ], [ 1, 'b' ], [ 0, 'a' ], [ 1, 'b' ], [ 2, 'c' ] ]
//function
var tl = [ [ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 3, 'a' ], [ 1, 'b' ],[2,'c'] ]
tlist.rmFirstKV(tl,2,'c')
////
[ [ 0, 'a' ], [ 1, 'b' ], [ 3, 'a' ], [ 1, 'b' ], [ 2, 'c' ] ]
rmFirstV(tl, v) → {Array}
rmFirstV
Parameters:
| Name | Type | Description |
|---|---|---|
tl |
Array | tlist |
v |
String | Number | value |
Returns:
tl - [t0,t1,...tk...,tn]
- Type
- Array
Example
term
//prototype
var tl = new Tlist([ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 0, 'a' ], [ 1, 'b' ],[2,'c'])
tl.rmFirstV('b')
////
Tlist [ [ 0, 'a' ], [ 2, 'c' ], [ 0, 'a' ], [ 1, 'b' ], [ 2, 'c' ] ]
//function
var tl = [ [ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 3, 'a' ], [ 1, 'b' ],[2,'c'] ]
tlist.rmFirstV(tl,'c')
////
[ [ 0, 'a' ], [ 1, 'b' ], [ 3, 'a' ], [ 1, 'b' ], [ 2, 'c' ] ]
rmK(tl, k, which) → {Array}
rmK
Parameters:
| Name | Type | Description |
|---|---|---|
tl |
Array | tlist |
k |
String | Number | key |
which |
Number | index |
Returns:
tl - [t0,t1,...tk...,tn]
- Type
- Array
Example
term
//prototype
var tl = new Tlist([ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 0, 'a' ], [ 1, 'b' ],[2,'c'])
var tl1 = tl.rmK(1,1)
tl1
var tl2 = tl.rmK(1,0)
tl2
////
>tl1
Tlist [ [ 0, 'a' ], [ 1, 'b' ], [ 2, 'c' ], [ 0, 'a' ], [ 2, 'c' ] ]
>tl2
Tlist [ [ 0, 'a' ], [ 2, 'c' ], [ 0, 'a' ], [ 1, 'b' ], [ 2, 'c' ] ]
//function
var tl = [ [ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 3, 'a' ], [ 1, 'b' ],[2,'c'] ]
tlist.rmK(tl,1,1)
////
[ [ 0, 'a' ], [ 1, 'b' ], [ 2, 'c' ], [ 3, 'a' ], [ 2, 'c' ] ]
rmKV(tl, k, v, which) → {Array}
rmKV
Parameters:
| Name | Type | Description |
|---|---|---|
tl |
Array | tlist |
k |
String | Number | key |
v |
String | Number | value |
which |
Number | index |
Returns:
tl - [t0,t1,...tk...,tn]
- Type
- Array
Example
term
//prototype
var tl = new Tlist([ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 0, 'a' ], [ 1, 'b' ],[2,'c'])
var tl1 = tl.rmKV(1,'b',1)
tl1
var tl2 = tl.rmKV(1,'b',0)
tl2
////
>tl1
Tlist [ [ 0, 'a' ], [ 1, 'b' ], [ 2, 'c' ], [ 0, 'a' ], [ 2, 'c' ] ]
>tl2
Tlist [ [ 0, 'a' ], [ 2, 'c' ], [ 0, 'a' ], [ 1, 'b' ], [ 2, 'c' ] ]
//function
var tl = [ [ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 3, 'a' ], [ 1, 'b' ],[2,'c'] ]
tlist.rmKV(tl,1,'b',1)
////
[ [ 0, 'a' ], [ 1, 'b' ], [ 2, 'c' ], [ 3, 'a' ], [ 2, 'c' ] ]
rmLastK(tl, k) → {Array}
rmLastK
Parameters:
| Name | Type | Description |
|---|---|---|
tl |
Array | tlist |
k |
String | Number | key |
Returns:
tl - [t0,t1,...tk...,tn
- Type
- Array
Example
term
//prototype
var tl = new Tlist([ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 0, 'a' ], [ 1, 'b' ],[2,'c'])
tl.rmLastK(1)
////
Tlist [ [ 0, 'a' ], [ 1, 'b' ], [ 2, 'c' ], [ 0, 'a' ], [ 2, 'c' ] ]
//function
var tl = [ [ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 3, 'a' ], [ 1, 'b' ],[2,'c'] ]
tlist.rmLastK(tl,1)
////
[ [ 0, 'a' ], [ 1, 'b' ], [ 2, 'c' ], [ 3, 'a' ], [ 2, 'c' ] ]
rmLastKV(tl, k, v) → {Array}
rmLastKV
Parameters:
| Name | Type | Description |
|---|---|---|
tl |
Array | tlist |
k |
String | Number | key |
v |
String | Number | value |
Returns:
tl - [t0,t1,...tk...,tn]
- Type
- Array
Example
term
//prototype
var tl = new Tlist([ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 0, 'a' ], [ 1, 'b' ],[2,'c'])
tl.rmLastKV(2,'c')
////
Tlist [ [ 0, 'a' ], [ 1, 'b' ], [ 2, 'c' ], [ 0, 'a' ], [ 1, 'b' ] ]
//function
var tl = [ [ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 3, 'a' ], [ 1, 'b' ],[2,'c'] ]
tlist.rmLastKV(tl,2,'c')
////
[ [ 0, 'a' ], [ 1, 'b' ], [ 2, 'c' ], [ 3, 'a' ], [ 1, 'b' ] ]
rmLastV(tl, v) → {Array}
rmLastV
Parameters:
| Name | Type | Description |
|---|---|---|
tl |
Array | tlist |
v |
String | Number | value |
Returns:
tl - [t0,t1,...tk...,tn]
- Type
- Array
Example
term
//prototype
var tl = new Tlist([ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 0, 'a' ], [ 1, 'b' ],[2,'c'])
tl.rmLastV('c')
////
Tlist [ [ 0, 'a' ], [ 1, 'b' ], [ 2, 'c' ], [ 0, 'a' ], [ 1, 'b' ] ]
//function
var tl = [ [ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 3, 'a' ], [ 1, 'b' ],[2,'c'] ]
tlist.rmLastV(tl,'c')
tl
////
[ [ 0, 'a' ], [ 1, 'b' ], [ 2, 'c' ], [ 3, 'a' ], [ 1, 'b' ] ]
rmV(tl, v, which) → {Array}
rmV
Parameters:
| Name | Type | Description |
|---|---|---|
tl |
Array | tlist |
v |
String | Number | value |
which |
Number | index |
Returns:
tl - [t0,t1,...tk...,tn]
- Type
- Array
Example
term
//prototype
var tl = new Tlist([ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 0, 'a' ], [ 1, 'b' ],[2,'c'])
var tl1 = tl.rmV('a',1)
tl1
var tl2 = tl.rmV('a',0)
tl2
////
> tl1
Tlist [ [ 0, 'a' ], [ 1, 'b' ], [ 2, 'c' ], [ 1, 'b' ], [ 2, 'c' ] ]
> tl2
Tlist [ [ 1, 'b' ], [ 2, 'c' ], [ 0, 'a' ], [ 1, 'b' ], [ 2, 'c' ] ]
//function
var tl = [ [ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 3, 'a' ], [ 1, 'b' ],[2,'c'] ]
tlist.rmV(tl,'a',1)
////
[ [ 0, 'a' ], [ 1, 'b' ], [ 2, 'c' ], [ 1, 'b' ], [ 2, 'c' ] ]
set(tl, k, v, which) → {Array}
set
this will change the original tlist
Parameters:
| Name | Type | Description |
|---|---|---|
tl |
Array | tlist |
k |
String | Number | key |
v |
String | Number | value |
which |
Number | index |
Returns:
tl - [t0,t1,...tk...,tn]
- Type
- Array
Example
term
//prototype
var tl = new Tlist([ 0, 'a' ], [ 'k', 'b' ],[2, 'c'], [ 3, 'a' ], [ 'k', 'b' ],[2,'c'])
tl.set('k','vv',1)
tl.set('k','vvv',0)
////
> tl.set('k','vv',1)
Tlist [
[ 0, 'a' ],
[ 'k', 'b' ],
[ 2, 'c' ],
[ 3, 'a' ],
[ 'k', 'vv' ],
[ 2, 'c' ] ]
>
> tl.set('k','vvv',0)
Tlist [
[ 0, 'a' ],
[ 'k', 'vvv' ],
[ 2, 'c' ],
[ 3, 'a' ],
[ 'k', 'vv' ],
[ 2, 'c' ] ]
>
//function
var tl = [ [ 0, 'a' ], [ 'k', 'b' ],[2, 'c'], [ 3, 'a' ], [ 'k', 'b' ],[2,'c'] ]
tlist.set(tl,'k','vv',1)
tl
////
> tlist.set(tl,'k','vv',1)
[ [ 0, 'a' ],
[ 'k', 'b' ],
[ 2, 'c' ],
[ 3, 'a' ],
[ 'k', 'vv' ],
[ 2, 'c' ] ]
> tl
[ [ 0, 'a' ],
[ 'k', 'b' ],
[ 2, 'c' ],
[ 3, 'a' ],
[ 'k', 'vv' ],
[ 2, 'c' ] ]
>
setAll(tl, k, v) → {Array}
setAll
this will change the original tlist
Parameters:
| Name | Type | Description |
|---|---|---|
tl |
Array | tlist |
k |
String | Number | key |
v |
String | Number | value |
Returns:
tl - [t0,t1,...tk...,tn]
- Type
- Array
Example
term
//prototype
var tl = new Tlist([ 0, 'a' ], [ 'k', 'b' ],[2, 'c'], [ 3, 'a' ], [ 'k', 'b' ],[2,'c'])
tl.setAll('k','vv')
////
> tl.setAll('k','vv')
Tlist [
[ 0, 'a' ],
[ 'k', 'vv' ],
[ 2, 'c' ],
[ 3, 'a' ],
[ 'k', 'vv' ],
[ 2, 'c' ] ]
>
//function
var tl = [ [ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 3, 'a' ], [ 1, 'b' ],[2,'c'] ]
tlist.setAll(tl,1,'xx')
tl
////
> tlist.setAll(tl,1,'xx')
[ [ 0, 'a' ],
[ 1, 'xx' ],
[ 2, 'c' ],
[ 3, 'a' ],
[ 1, 'xx' ],
[ 2, 'c' ] ]
>
> tl
[ [ 0, 'a' ],
[ 1, 'xx' ],
[ 2, 'c' ],
[ 3, 'a' ],
[ 1, 'xx' ],
[ 2, 'c' ] ]
>
setFirst(tl, k, v, which) → {Array}
setFirst
this will change the original tlist
Parameters:
| Name | Type | Description |
|---|---|---|
tl |
Array | tlist |
k |
String | Number | key |
v |
String | Number | value |
which |
Number | index |
Returns:
tl - [t0,t1,...tk...,tn]
- Type
- Array
Example
term
//prototype
var tl = new Tlist([ 0, 'a' ], [ 'k', 'b' ],[2, 'c'], [ 3, 'a' ], [ 'k', 'b' ],[2,'c'])
tl.setFirst('k','vv')
////
> tl.setFirst('k','vv')
Tlist [
[ 0, 'a' ],
[ 'k', 'vv' ],
[ 2, 'c' ],
[ 3, 'a' ],
[ 'k', 'b' ],
[ 2, 'c' ] ]
>
//function
var tl = [ [ 0, 'a' ], [ 'k', 'b' ],[2, 'c'], [ 3, 'a' ], [ 'k', 'b' ],[2,'c'] ]
tlist.setFirst(tl,'k','vv')
tl
////
> tlist.setFirst(tl,'k','vv')
[ [ 0, 'a' ],
[ 'k', 'vv' ],
[ 2, 'c' ],
[ 3, 'a' ],
[ 'k', 'b' ],
[ 2, 'c' ] ]
> tl
[ [ 0, 'a' ],
[ 'k', 'vv' ],
[ 2, 'c' ],
[ 3, 'a' ],
[ 'k', 'b' ],
[ 2, 'c' ] ]
>
setLast(tl, k, v, which) → {Array}
setLast
this will change the original tlist
Parameters:
| Name | Type | Description |
|---|---|---|
tl |
Array | tlist |
k |
String | Number | key |
v |
String | Number | value |
which |
Number | index |
Returns:
tl - [t0,t1,...tk...,tn]
- Type
- Array
Example
term
//prototype
var tl = new Tlist([ 0, 'a' ], [ 'k', 'b' ],[2, 'c'], [ 3, 'a' ], [ 'k', 'b' ],[2,'c'])
tl.setLast('k','vv')
////
[ [ 0, 'a' ],
[ 'k', 'b' ],
[ 2, 'c' ],
[ 3, 'a' ],
[ 'k', 'vv' ],
[ 2, 'c' ] ]
//function
var tl = [ [ 0, 'a' ], [ 'k', 'b' ],[2, 'c'], [ 3, 'a' ], [ 'k', 'b' ],[2,'c'] ]
tlist.setLast(tl,'k','vv')
tl
////
> tlist.setLast(tl,'k','vv')
[ [ 0, 'a' ],
[ 'k', 'b' ],
[ 2, 'c' ],
[ 3, 'a' ],
[ 'k', 'vv' ],
[ 2, 'c' ] ]
> tl
[ [ 0, 'a' ],
[ 'k', 'b' ],
[ 2, 'c' ],
[ 3, 'a' ],
[ 'k', 'vv' ],
[ 2, 'c' ] ]
>
sortk(tl) → {Array}
sortk
Parameters:
| Name | Type | Description |
|---|---|---|
tl |
Array | tlist |
Returns:
tl - [t0,t1,...tk...,tn]
- Type
- Array
Example
term
//prototype
var tl = new Tlist([ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 3, 'a' ], [ 1, 'b' ],[2,'c'])
tl.sortk()
tl
////
> tl.sortk()
Tlist [
[ 0, 'a' ],
[ 1, 'b' ],
[ 1, 'b' ],
[ 2, 'c' ],
[ 2, 'c' ],
[ 3, 'a' ] ]
>
//function
var tl = [ [ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 3, 'a' ], [ 1, 'b' ],[2,'c'] ]
tlist.sortk(tl)
////
> tlist.sortk(tl)
[ [ 0, 'a' ],
[ 1, 'b' ],
[ 1, 'b' ],
[ 2, 'c' ],
[ 2, 'c' ],
[ 3, 'a' ] ]
sortkv(tl) → {Array}
sortkv
sort will first compare key, and then compare value
Parameters:
| Name | Type | Description |
|---|---|---|
tl |
Array | tlist |
Returns:
tl - [t0,t1,...tk...,tn]
- Type
- Array
Example
term
//prototype
var tl = new Tlist([ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 3, 'a' ], [ 1, 'b' ],[2,'c'])
tl.sortkv()
tl
////
> tl.sortkv()
Tlist [
[ 0, 'a' ],
[ 1, 'b' ],
[ 1, 'b' ],
[ 2, 'c' ],
[ 2, 'c' ],
[ 3, 'a' ] ]
>
> tl
Tlist [
[ 0, 'a' ],
[ 1, 'b' ],
[ 2, 'c' ],
[ 3, 'a' ],
[ 1, 'b' ],
[ 2, 'c' ] ]
>
//function
var tl = [ [ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 3, 'a' ], [ 1, 'b' ],[2,'c'] ]
tlist.sortkv(tl)
////
> tlist.sortkv(tl)
[ [ 0, 'a' ],
[ 1, 'b' ],
[ 1, 'b' ],
[ 2, 'c' ],
[ 2, 'c' ],
[ 3, 'a' ] ]
sortv(tl) → {Array}
sortv
Parameters:
| Name | Type | Description |
|---|---|---|
tl |
Array | tlist |
Returns:
tl - [t0,t1,...tk...,tn]
- Type
- Array
Example
term
//prototype
var tl = new Tlist([ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 3, 'a' ], [ 1, 'b' ],[2,'c'])
tl.sortv()
tl
////
> tl.sortv()
Tlist [
[ 0, 'a' ],
[ 3, 'a' ],
[ 1, 'b' ],
[ 1, 'b' ],
[ 2, 'c' ],
[ 2, 'c' ] ]
>
> tl
Tlist [
[ 0, 'a' ],
[ 1, 'b' ],
[ 2, 'c' ],
[ 3, 'a' ],
[ 1, 'b' ],
[ 2, 'c' ] ]
>
//function
var tl = [ [ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 3, 'a' ], [ 1, 'b' ],[2,'c'] ]
tlist.sortv(tl)
////
> tlist.sortv(tl)
[ [ 0, 'a' ],
[ 3, 'a' ],
[ 1, 'b' ],
[ 1, 'b' ],
[ 2, 'c' ],
[ 2, 'c' ] ]
sortvk(tl) → {Array}
sortvk
sort will first compare value, and then compare key
Parameters:
| Name | Type | Description |
|---|---|---|
tl |
Array | tlist |
Returns:
tl - [t0,t1,...tk...,tn]
- Type
- Array
Example
term
//prototype
var tl = new Tlist([ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 3, 'a' ], [ 1, 'b' ],[2,'c'])
tl.sortvk()
tl
////
> tl.sortvk()
Tlist [
[ 0, 'a' ],
[ 3, 'a' ],
[ 1, 'b' ],
[ 1, 'b' ],
[ 2, 'c' ],
[ 2, 'c' ] ]
> tl
Tlist [
[ 0, 'a' ],
[ 1, 'b' ],
[ 2, 'c' ],
[ 3, 'a' ],
[ 1, 'b' ],
[ 2, 'c' ] ]
>
//function
var tl = [ [ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 3, 'a' ], [ 1, 'b' ],[2,'c'] ]
tlist.sortvk(tl)
////
[ [ 0, 'a' ],
[ 3, 'a' ],
[ 1, 'b' ],
[ 1, 'b' ],
[ 2, 'c' ],
[ 2, 'c' ] ]
t2d(t) → {Object}
t2d
Parameters:
| Name | Type | Description |
|---|---|---|
t |
Object | tuple |
Returns:
d - dict
- Type
- Object
Example
term
//prototype
////
//function
tlist.t2d(['a',1])
////
> tlist.t2d(['a',1])
{ a: 1 }
tl2d(tl) → {Object}
tl2d
Parameters:
| Name | Type | Description |
|---|---|---|
tl |
Array | tlist |
Returns:
d - dict
- Type
- Object
Example
term
//prototype
var tl = new Tlist(0,'a',1,'b',2,'c')
tl.dict()
////
{ '0': 'a', '1': 'b', '2': 'c' }
//function
var tl = [ [ 0, 'a' ], [ 0, 'b' ], [ 1, 'a' ], [ 1, 'b' ] ]
tlist.tl2d(tl)
////
> tlist.tl2d(tl)
{ '0': 'b', '1': 'b' }
tl2kvl(tl) → {Array}
tl2kvl
Parameters:
| Name | Type | Description |
|---|---|---|
tl |
Array | tlist |
Returns:
kvl - [kl,vl]
- Type
- Array
Example
term
//prototype
var tl = new Tlist([ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 0, 'a' ], [ 1, 'b' ],[2,'c'])
tl2.kvl()
[ [ '0', '1', '2' ], [ 'a', 'b', 'c' ] ]
////
//function
var tl = [ [ 0, 'a' ], [ 1, 'b' ], [ 2, 'a' ], [ 3, 'b' ] ]
var [kl,vl] = tlist.tl2kvl(tl)
kl
vl
////
> kl
[ 0, 1, 2, 3 ]
> vl
[ 'a', 'b', 'a', 'b' ]
>
tl2l(tl) → {Array}
tl2l
Parameters:
| Name | Type | Description |
|---|---|---|
tl |
Array | tlist |
Returns:
l - list
- Type
- Array
Example
term
//prototype
var tl = new Tlist([ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 0, 'a' ], [ 1, 'b' ],[2,'c'])
tl.list()
////
[ 0, 'a', 1, 'b', 2, 'c', 0, 'a', 1, 'b', 2, 'c' ]
//function
var tl = [ [ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 0, 'a' ], [ 1, 'b' ],[2,'c'] ]
tlist.tl2l(tl)
////
> tlist.tl2l(tl)
[ 0, 'a', 1, 'b', 2, 'c', 0, 'a', 1, 'b', 2, 'c' ]
tupleCmpK(t0, t1) → {Boolean}
tupleCmpK
t0 = [k0,v0]
t1 = [k1,v1]
compare k0,k1
Parameters:
| Name | Type | Description |
|---|---|---|
t0 |
Array | tuple |
t1 |
Array | tuple |
Returns:
rslt - rslt
- Type
- Boolean
Example
term
//prototype
////
//function
////
tupleCmpKV(t0, t1) → {Boolean}
Parameters:
| Name | Type | Description |
|---|---|---|
t0 |
Array | tuple |
t1 |
Array | tuple |
Returns:
rslt - rslt
- Type
- Boolean
Example
term
//prototype
////
//function
////
tupleCmpV(t0, t1) → {Boolean}
tupleCmpV
t0 = [k0,v0]
t1 = [k1,v1]
compare v0,v1
Parameters:
| Name | Type | Description |
|---|---|---|
t0 |
Array | tuple |
t1 |
Array | tuple |
Returns:
rslt - rslt
- Type
- Boolean
Example
term
//prototype
////
//function
////
tupleCmpVK(t0, t1) → {Boolean}
tupleCmpVK
t0 =[k0,v0]
t1 =[k1,v1]
first compare v0,v1, then compare k0,k1
Parameters:
| Name | Type | Description |
|---|---|---|
t0 |
Array | tuple |
t1 |
Array | tuple |
Returns:
rslt - rslt
- Type
- Boolean
Example
term
//prototype
////
//function
tlist.tupleCmpVK(['a',2],['b',1])
tlist.tupleCmpVK(['a',2],['b',3]
tlist.tupleCmpVK(['a',2],['b',2])
tlist.tupleCmpVK(['a',2],['a',2])
////
tupleEq(t0, t1) → {Boolean}
tupleEq
t0 = [k0,v0]
t1 = [k1,v1]
if(k0===k1 && v0 === v1) then t0===t1
Parameters:
| Name | Type | Description |
|---|---|---|
t0 |
Array | tuple |
t1 |
Array | tuple |
Returns:
rslt - rslt
- Type
- Boolean
Example
term
//prototype
////
//function
////
tupleEqK(t0, t1) → {Boolean}
tupleEqK
t0 = [k0,v0]
t1 = [k1,v1]
if(k0===k1) then t0===t1
Parameters:
| Name | Type | Description |
|---|---|---|
t0 |
Array | tuple |
t1 |
Array | tuple |
Returns:
rslt - rslt
- Type
- Boolean
Example
term
//prototype
////
//function
////
tupleEqKV(t0, t1) → {Boolean}
tupleEqKV
t0 = [k0,v0]
t1 = [k1,v1]
if(k0===k1 && v0 === v1) then t0===t1
Parameters:
| Name | Type | Description |
|---|---|---|
t0 |
Array | tuple |
t1 |
Array | tuple |
Returns:
rslt - rslt
- Type
- Boolean
Example
term
//prototype
////
//function
////
tupleEqV(t0, t1) → {Boolean}
tupleEqV
t0 = [k0,v0]
t1 = [k1,v1]
if(v0 === v1) then t0===t1
Parameters:
| Name | Type | Description |
|---|---|---|
t0 |
Array | tuple |
t1 |
Array | tuple |
Returns:
rslt - rslt
- Type
- Boolean
Example
term
//prototype
////
//function
////
tupleGtK(t0, t1) → {Boolean}
tupleGtK
t0 = [k0,v0]
t1 = [k1,v1]
if(k0 > k1) then t0>t1
Parameters:
| Name | Type | Description |
|---|---|---|
t0 |
Array | tuple |
t1 |
Array | tuple |
Returns:
rslt - rslt
- Type
- Boolean
Example
term
//prototype
////
//function
////
tupleGtV(t0, t1) → {Boolean}
tupleGtV
t0 = [k0,v0]
t1 = [k1,v1]
if(v0 > v1) then t0>t1
Parameters:
| Name | Type | Description |
|---|---|---|
t0 |
Array | tuple |
t1 |
Array | tuple |
Returns:
rslt - rslt
- Type
- Boolean
Example
term
//prototype
////
//function
////
tupleLtK(t0, t1) → {Boolean}
tupleLtK
t0 = [k0,v0]
t1 = [k1,v1]
if(k0 < k1) then t0
Parameters:
| Name | Type | Description |
|---|---|---|
t0 |
Array | tuple |
t1 |
Array | tuple |
Returns:
rslt - rslt
- Type
- Boolean
Example
term
//prototype
////
//function
////
tupleLtV(t0, t1) → {Boolean}
tupleLtV
t0 = [k0,v0]
t1 = [k1,v1]
if(v0 < v1) then t0
Parameters:
| Name | Type | Description |
|---|---|---|
t0 |
Array | tuple |
t1 |
Array | tuple |
Returns:
rslt - rslt
- Type
- Boolean
Example
term
//prototype
////
//function
////
uniqualizeAllK(tl) → {Array}
uniqualizeAllK
Parameters:
| Name | Type | Description |
|---|---|---|
tl |
Array | tlist |
Returns:
tl - [t0,t1,...tk...,tn]
- Type
- Array
Example
term
//prototype
var tl = new Tlist([ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 0, 'a' ], [ 1, 'b' ],[2,'c'])
tl.uniqualizeAllK()
////
[[ 0, 'a' ], [ 1, 'b' ],[2, 'c']]
//function
var tl = [ [ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 3, 'a' ], [ 1, 'b' ],[2,'c'] ]
tlist.uniqualizeAllK(tl)
////
> tlist.uniqualizeAllK(tl)
[ [ 0, 'a' ], [ 1, 'b' ], [ 2, 'c' ], [ 3, 'a' ] ]
uniqualizeAllKV(tl) → {Array}
uniqualizeAllKV
Parameters:
| Name | Type | Description |
|---|---|---|
tl |
Array | tlist |
Returns:
tl - [t0,t1,...tk...,tn]
- Type
- Array
Example
term
//prototype
var tl = new Tlist([ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 0, 'a' ], [ 1, 'b' ],[2,'c'])
tl.uniqualizeAllKV()
tl
////
[ [ 0, 'a' ], [ 1, 'b' ], [ 2, 'c' ] ]
//function
var tl = [ [ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 0, 'a' ], [ 1, 'b' ],[2,'c'] ]
tlist.uniqualizeAllKV(tl)
////
> tlist.uniqualizeAllKV(tl)
[ [ 0, 'a' ], [ 1, 'b' ], [ 2, 'c' ] ]
uniqualizeAllV(tl, v) → {Array}
uniqualizeAllV
Parameters:
| Name | Type | Description |
|---|---|---|
tl |
Array | tlist |
v |
String | Number | value |
Returns:
tl - [t0,t1,...tk...,tn]
- Type
- Array
Example
term
//prototype
var tl = new Tlist([ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 0, 'a' ], [ 1, 'b' ],[2,'c'])
tl.uniqualizeAllV()
////
[ [ 0, 'a' ], [ 1, 'b' ], [ 2, 'c' ] ]
//function
var tl = [ [ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 3, 'a' ], [ 1, 'b' ],[2,'c'] ]
tlist.uniqualizeAllV(tl)
////
> tlist.uniqualizeAllV(tl)
[ [ 3, 'a' ], [ 1, 'b' ], [ 2, 'c' ] ]
uniqualizeK(tl, k) → {Array}
uniqualizeK
Parameters:
| Name | Type | Description |
|---|---|---|
tl |
Array | tlist |
k |
String | Number | key |
Returns:
tl - [t0,t1,...tk...,tn]
- Type
- Array
Example
term
//prototype
var tl = new Tlist([ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 0, 'a' ], [ 1, 'b' ],[2,'c'])
tl.uniqualizeK(1)
////
[ [ 0, 'a' ], [ 1, 'b' ], [ 2, 'c' ], [ 3, 'a' ], [ 2, 'c' ] ]
//function
var tl = [ [ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 3, 'a' ], [ 1, 'b' ],[2,'c'] ]
tlist.uniqualizeK(tl,1)
////
[ [ 0, 'a' ], [ 1, 'b' ], [ 2, 'c' ], [ 3, 'a' ], [ 2, 'c' ] ]
uniqualizeKV(tl, k, v) → {Array}
uniqualizeKV
Parameters:
| Name | Type | Description |
|---|---|---|
tl |
Array | tlist |
k |
String | Number | key |
v |
String | Number | value |
Returns:
tl - [t0,t1,...tk...,tn]
- Type
- Array
Example
term
//prototype
var tl = new Tlist([ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 0, 'a' ], [ 1, 'b' ],[2,'c'])
tl.uniqualizeKV(0,'a')
tl
////
[ [ 0, 'a' ], [ 1, 'b' ], [ 2, 'c' ], [ 1, 'b' ], [ 2, 'c' ] ]
//function
var tl = [ [ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 0, 'a' ], [ 1, 'b' ],[2,'c'] ]
tlist.uniqualizeKV(tl,1,'b')
////
> tlist.uniqualizeKV(tl,1,'b')
[ [ 0, 'a' ], [ 1, 'b' ], [ 2, 'c' ], [ 0, 'a' ], [ 2, 'c' ] ]
uniqualizeV(tl, v) → {Array}
uniqualizeV
Parameters:
| Name | Type | Description |
|---|---|---|
tl |
Array | tlist |
v |
String | Number | value |
Returns:
tl - [t0,t1,...tk...,tn]
- Type
- Array
Example
term
//prototype
var tl = new Tlist([ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 0, 'a' ], [ 1, 'b' ],[2,'c'])
tl.uniqualizeV('a')
////
[ [ 0, 'a' ], [ 1, 'b' ], [ 2, 'c' ], [ 1, 'b' ], [ 2, 'c' ] ]
//function
var tl = [ [ 0, 'a' ], [ 1, 'b' ],[2, 'c'], [ 3, 'a' ], [ 1, 'b' ],[2,'c'] ]
tlist.uniqualizeV(tl,'a')
////
> tlist.uniqualizeV(tl,'a')
[ [ 3, 'a' ], [ 1, 'b' ], [ 2, 'c' ], [ 1, 'b' ], [ 2, 'c' ] ]