开发者

Filling a queue from another queue in reverse order

It is also too easy maybe. How can I 开发者_开发知识库fill the B queue by A queue? but B queue must be reverse.


What about just

val b = a.reverse


Assuming Queue is a FIFO, if you can take from the end of the queue, just take from the end of A and put them into B.

If you can't, take A from the front, insert them on a Stack, then when A is empty, put them off the stack into B.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜