This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.then(() => { | |
var i = 0; | |
const whileHeapList = () => { | |
i++; | |
if (i < 5) { | |
// artifically delayed call | |
log.asyncCall().then(log => { | |
if (log) { | |
// first inner loop | |
const firstInnerLoop = () => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.then(() => { | |
var i = 0; | |
const whileHeapList = () => { | |
i++; | |
if (i < 5) { | |
// artifically delayed call | |
log.asyncCall().then(log => { | |
if (log) { | |
// first inner loop | |
const firstInnerLoop = () => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const innerWhileLoop = () => { | |
if (i <= j) { | |
i++; | |
// continue | |
innerWhileLoop(); | |
} else { | |
// stop iteration | |
new Promise.resolve(); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// nested Loop | |
.then(() => { | |
var heaplist = 4; | |
const whileHeapList = () => { | |
if (heaplist) { | |
heaplist--; | |
var i = 0; | |
var j = 5; | |
const innerWhileLoop = () => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const wait = fnc => new Promise(fnc => setTimeout(fnc, 0)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const whileHeapList = () => { | |
var heapNode = null; | |
var currTimestamp = null; | |
var nextMinTimestamp = null; | |
if (minheap.heapList.length) { | |
heapNode = minheap.popMin(); | |
currTimestamp = heapNode['ts']; | |
printer.print(heapNode.data); | |
nextMinTimestamp = minheap.getPeakTimestamp(); | |
const whileCurrTimestampLTENextMinTimestamp = () => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Promise.all(logSources.map(logSource => { | |
logSource.popAsync().then(log => { | |
minheap.insert({ | |
ts: log.date.getTime(), | |
source: i, | |
data: log | |
}) | |
}); | |
}).then( | |
while (minheap.heapList.length) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.then( | |
while (minheap.heapList.length) { | |
let heapNode = minheap.popMin(); | |
let currTimestamp = heapNode['ts']; | |
printer.print(heapNode.data); | |
let nextMinTimestamp = minheap.getPeakTimestamp(); | |
while (currTimestamp <= nextMinTimestamp) { | |
logSources[heapNode['source']].popAsync().then(log => { | |
if (log) { | |
let logtime = log.date.getTime(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.then( | |
while (minheap.heapList.length) { | |
let heapNode = minheap.popMin(); | |
let currTimestamp = heapNode['ts']; | |
printer.print(heapNode.data); | |
let nextMinTimestamp = minheap.getPeakTimestamp(); | |
while (currTimestamp <= nextMinTimestamp) { | |
logSources[heapNode['source']].popAsync().then(log => { | |
if (log) { | |
let logtime = log.date.getTime(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def searchRange(nums, target): | |
""" | |
:type nums: List[int] | |
:type target: int | |
:rtype: List[int] | |
""" | |
if nums: | |
return search(nums, 0, len(nums) - 1, target) | |
return [-1,-1] |