Click here to Skip to main content
15,897,519 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
GeneralProblem with GUID Pin
Gabriel.P.G3-Nov-03 16:35
Gabriel.P.G3-Nov-03 16:35 
GeneralRe: Problem with GUID Pin
umeca743-Nov-03 21:24
umeca743-Nov-03 21:24 
GeneralRe: Problem with GUID Pin
Gabriel.P.G4-Nov-03 5:57
Gabriel.P.G4-Nov-03 5:57 
Generaliterator. Pin
WREY3-Nov-03 12:46
WREY3-Nov-03 12:46 
GeneralRe: iterator. Pin
Michael Dunn3-Nov-03 16:56
sitebuilderMichael Dunn3-Nov-03 16:56 
GeneralRe: iterator. Pin
WREY3-Nov-03 17:55
WREY3-Nov-03 17:55 
GeneralRe: iterator. Pin
Stuart Dootson3-Nov-03 21:13
professionalStuart Dootson3-Nov-03 21:13 
GeneralRe: iterator. Pin
ZoogieZork3-Nov-03 19:01
ZoogieZork3-Nov-03 19:01 
Michael Dunn has the right idea. The key concept of iterators is that they are an abstraction for accessing containers and don't necessarily know their own position. For example, take the iterator for the std::list template. This iterator implements the bidirectional iterator model meaning that it merely needs to know the previous node and the next node in a container. For std::list, that means that it just needs a reference to a single node in the doubly-linked list -- it has no concept of where that node is in the list.

Here's an example as to why this is important: Let's say that you have a list and you start iterating through it. Somewhere in the middle, you insert a node somewhere in the list. This does not invalidate the iterator, so you can still happily keep moving around the list. If the iterators kept track of the position, the list would have to keep track of every single iterator and notify them that their position has been changed. Or they could just get invalidated, which is worse.

Even a std::vector iterator (which implements the random access iterator model) probably doesn't know what position in the vector it points to -- most implementations just store a pointer to the item, not an index, and some older implementations typedef the iterator type to a pointer directly! However, it means that it can find out the relative distance to another iterator, so subtracting iterators produces a useful result.

As far as I can tell, only a random access iterator needs to implement subtraction. Other iterator types probably won't compile when you try to subtract them.

- Mike
GeneralRe: iterator. Pin
Stuart Dootson3-Nov-03 21:16
professionalStuart Dootson3-Nov-03 21:16 
GeneralRe: iterator. Pin
Jörgen Sigvardsson6-Nov-03 13:50
Jörgen Sigvardsson6-Nov-03 13:50 
GeneralRe: iterator. Pin
Stuart Dootson6-Nov-03 22:22
professionalStuart Dootson6-Nov-03 22:22 
GeneralRe: iterator. Pin
ZoogieZork3-Nov-03 19:14
ZoogieZork3-Nov-03 19:14 
GeneralRe: iterator. Pin
WREY3-Nov-03 22:16
WREY3-Nov-03 22:16 
GeneralDlg's; Pin
Bo Hunter3-Nov-03 12:01
Bo Hunter3-Nov-03 12:01 
GeneralRe: Dlg's; Pin
Michael Dunn3-Nov-03 16:57
sitebuilderMichael Dunn3-Nov-03 16:57 
Questioncan i set the height of the item in CListViewCtrl and add a image for every item? Pin
HeartFriend2-Nov-03 21:07
HeartFriend2-Nov-03 21:07 
AnswerRe: can i set the height of the item in CListViewCtrl and add a image for every item? Pin
Dudi Avramov3-Nov-03 4:26
Dudi Avramov3-Nov-03 4:26 
AnswerRe: can i set the height of the item in CListViewCtrl and add a image for every item? Pin
Mil104-Nov-03 2:46
Mil104-Nov-03 2:46 
QuestionOLEDB issue new with MDAC 2.8? Pin
Steve S31-Oct-03 1:37
Steve S31-Oct-03 1:37 
GeneralDHTM binary behavior Pin
jackalwisdom30-Oct-03 22:38
jackalwisdom30-Oct-03 22:38 
GeneralReference to object using handle Pin
Member 60189830-Oct-03 18:24
Member 60189830-Oct-03 18:24 
GeneralContext Menu on web page shown ... Pin
byblostas30-Oct-03 11:11
byblostas30-Oct-03 11:11 
GeneralGetting notification on <CR> from Edit control Pin
janman30-Oct-03 0:49
janman30-Oct-03 0:49 
GeneralRe: Getting notification on <CR> from Edit control Pin
umeca741-Nov-03 1:29
umeca741-Nov-03 1:29 
GeneralRe: Getting notification on <CR> from Edit control Pin
janman1-Nov-03 22:42
janman1-Nov-03 22:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.