Wednesday 15 April 2015

c++ - Obtaining last node of BST from an iterator returned by end() function? -


I am struggling to understand the implementation requirements of the last () function, which triggers an error from the last element Pointing at What is the meaning of the last element? Will not it always be empty? And if there is no information in it, how can I get the last node of BST with the help of O (1) end, with the complexity of time?

The concept of a "blank" element is something that is not just in the iterator. It's really meaningless. Iterators are not raw Si pointers.

This is to design your iterators that gives the end node on end () - 1 on such a non-empty container, if iterator is to start with.

For the more common case of forward iterator, what you actually want is that some iterator is equal to < />

This is sometimes done due to being end (), indicates a special node The functionality of end () exists for convenience.

An Iterator can show a Boolean region which is the result of end () , for example. Iterator can keep as much information as you want, it is an adaptation to reduce that amount, but an alternate one.

is not the only available means of getting any operator for the start () and end () .

>

No comments:

Post a Comment