tag:blogger.com,1999:blog-789350385633370545.post2157526451216816732..comments2023-08-04T12:31:37.267+03:00Comments on Chasing state of the art: Queue based on a single stackDzmitry Hubahttp://www.blogger.com/profile/05927186761289385653noreply@blogger.comBlogger5125tag:blogger.com,1999:blog-789350385633370545.post-55370851136573051492012-09-18T08:08:52.438+03:002012-09-18T08:08:52.438+03:00The system stack (which enables recursive calling)...The system stack (which enables recursive calling) is also a stack. So you have two stacks involved.Rosshttps://www.blogger.com/profile/16367287655636396603noreply@blogger.comtag:blogger.com,1999:blog-789350385633370545.post-56572665723804225492010-01-21T21:42:51.791+02:002010-01-21T21:42:51.791+02:00Hi Andy.
Peeking or dequeuing from an empty queue...Hi Andy.<br /><br />Peeking or dequeuing from an empty queue must result in InvalidOperationException as there is nothing to return. In both cases the reason and description for the exception is the same so reusing exceptional case condition checking and exception raising code is reasonable.Dzmitry Hubahttps://www.blogger.com/profile/05927186761289385653noreply@blogger.comtag:blogger.com,1999:blog-789350385633370545.post-84492496425288532532010-01-21T17:46:27.329+02:002010-01-21T17:46:27.329+02:00Why do you use special function for ThrowIfEmpy()?...Why do you use special function for ThrowIfEmpy()? <br />This function does not know type of exception that should be thrown. It knows only caller.lotgonhttps://www.blogger.com/profile/11011756397839238979noreply@blogger.comtag:blogger.com,1999:blog-789350385633370545.post-11899083902779259552010-01-18T11:01:28.481+02:002010-01-18T11:01:28.481+02:00Enqueue pops topmost item from stack and then make...Enqueue pops topmost item from stack and then makes recursive call. Once base case is reached (stack is empty) it pushes item and returns. Upon return from recursive call it pushes previously popped item. Thus item appears at the bottom of the stack.Dzmitry Hubahttps://www.blogger.com/profile/05927186761289385653noreply@blogger.comtag:blogger.com,1999:blog-789350385633370545.post-16288005519448132382010-01-18T02:37:09.695+02:002010-01-18T02:37:09.695+02:00Stack[T].Pop doesn't return all items - it jus...Stack[T].Pop doesn't return <i>all</i> items - it just returns the topmost.<br /><br />So not sure how "var tmp = m_items.Pop();" would work out.<br /><br /><br />..Unless I'm missing something! :)<br /><br /><br /><br />Regards,<br /><a href="http://codevanced.net" rel="nofollow">Andrew</a>Andrew Kazyrevichhttps://www.blogger.com/profile/04046561837342984580noreply@blogger.com