-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsequence.js
32 lines (28 loc) · 852 Bytes
/
sequence.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
'use strict';
class Sequence {
constructor(events, count) {
this.events = events;
if (count == null) {
this.count = 1
} else {
this.count = count
}
//event1,event2....
this.id = events.toString()
}
getSubSequences() {
/**
* for sequence 1,2,3, will return 1, 12, 123, 2, 23, 3
*/
let result = new Object()
for(var i = 0; i < this.events.length; i = i + 1) {
//add all events sequence starting with this event(inclusive)
for (var j = 0; i + j < this.events.length; j = j + 1) {
let seq = new Sequence(this.events.slice(i, i + j + 1))
result[seq.id] = seq
}
}
return Object.keys(result).map(k => result[k])
}
}
module.exports = Sequence