impl orderdictionary filter

This commit is contained in:
Adhiraj Singh
2021-08-26 19:32:53 +05:30
parent 8a014df1c5
commit dc471b365a

View File

@@ -61,7 +61,15 @@ const makeOrderedDictionary = function<T>(idGetter: (item: T) => string) {
Object.keys(dict).forEach(key => { delete dict[key] })
},
filter: (contain: (item: T) => boolean) => {
//const copy =
let i = 0
while(i < array.length) {
if(!contain(array[i])) {
delete dict[idGetter(array[i])]
array.splice(i, 1)
} else {
i += 1
}
}
}
}
}