Thread: Though implementation problem

  1. #76
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Seems like you guys are struggling hard to invent terminology that already exists. See for instance the concepts:

    TrivialIterator
    InputIterator
    OutputIterator
    ForwardIterator
    BidirectionalIterator
    RandomAccessIterator

    and probably others.

    Elysia's "range iterator which can walk forwards and backwards" is a BidirectionalIterator.

    Also, using the word "range" produces confusion because boost already has a range concept, which is not really related to what you guys are talking about.

  2. #77
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by phantomotap View Post
    Ah, nope... you are still talking about inserting additional contents back in to the original container.
    That's not all there is to it.
    An iterator should allow you to set a new value, overwriting whatever may be there, as well as allow you to iterate through a vector or a set of results and allow you to see the keys as well as the actual value at any given element.
    It's no different from a normal iterator. It works in the exact same way.
    Replacing a value with a value of the same type. But since strings are variable, it may have to shift the data to make place. But that's really irrelevant.

    Why do you insist to call it insertion iterator?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #78
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by Elysia View Post
    Why do you insist to call it insertion iterator?
    Because shifting a piece of data to make room for something else is an insertion, by definition.

  4. #79
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    I guess, fair enough. It doesn't really matter what it's called, so long as it does what it should.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  5. #80
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    >> It doesn't really matter what it's called
    Well, of course it does matter. It has to be named clearly and correctly. Otherwise you would not be able to find it if you're new to the interface and it would be difficult to use (which we know is very important to you).

  6. #81
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Yes, I meant it doesn't matter what the proper definition of the iterator is as long as it does its job. It can be named iterator X or iterator Y for all I care. It does need a proper class name, however.
    But to me, it looks just like some range iterator.
    And currently I called one CStringExItRange. I don't know if that's good or bad.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  7. #82
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    Seems like you guys are struggling hard to invent terminology that already exists. See for instance the concepts:

    TrivialIterator
    InputIterator
    OutputIterator
    ForwardIterator
    BidirectionalIterator
    RandomAccessIterator

    and probably others.

    Elysia's "range iterator which can walk forwards and backwards" is a BidirectionalIterator.
    Hah! What a waste of time. A BidirectionalIterator is a ForwardIterator. Do you understand? Just in case you don't: ranged iterators are a further refinement of bidirectional iterators. (In much the same way as a 'back_inserter' is a refinement of ForwardIterator.) They, and I'm getting tired of saying this, imply certain abilities above and beyond what a normal iterator defines/allows. And no, what Elysia is asking for has no name to the extent of my knowledge, but it is certainly not a ranged iterator. (Naturally, that doesn't mean that a name doesn't exist in the canon.)

    Also, using the word "range" produces confusion because boost already has a range concept, which is not really related to what you guys are talking about.
    Hardly. You are right that the Boost range concept is different from a range iterator, but you are wrong in thinking that the Boost range concept predates range iterators. And I can't imagine any real confusion: the Boost range concept is a form of abstraction providing a container-like interface for traditionally non-compatible constructs whereas a range iterator is a kind of iterator inferring special behavior.

    Why do you insist to call it insertion iterator?
    Because, if the new content is longer than the old content, the additional content must be inserted.

    Soma
    Last edited by phantomotap; 05-12-2008 at 06:31 PM.

  8. #83
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Are we going to start flaming each other over the name of an iterator now?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  9. #84
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    The problem with this entire idiotic comment becomes obvious if you had actually read what has been posted.
    I don't appreciate your language. Especially when you're wrong.

    ranged iterators are a further refinement of bidirectional iterators.
    This idea is not supported by anything in the standard, the proposals for C++0x, or even Boost. Based on that, I can tell that you don't have the authority to criticize my previous post.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  10. #85
    Banned
    Join Date
    Nov 2007
    Posts
    678
    Elysia, i would like to see some specialized features inside string class, even when, there are generic options available!

    The people here (most of them) have this mentality of generic solutions, a one for all cure, which is not always possible! And tell me why we have for_each in C++ when the basic, and way more generalized for( ; ; ) loop is already there?

    Sick of it

    Elysia i will vote for you, although even you do not seem to put too many features (which is what i would like to have).
    Last edited by manav; 05-13-2008 at 02:40 AM.

  11. #86
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by manav View Post
    Elysia, i would like to see some specialized features inside string class, even when, there are generic options available!
    Absolutely. This is necessary.

    The people here (most of them) have this mentality of generic solutions, a one for all cure, which is not always possible! And tell me why we have for_each in C++ when the basic, and way more generalized for( ; ; ) loop is already there?
    The good thing with generic solutions is that you can reuse code! And C++ is good at that.
    But those generic solutions won't always do! So you would implement higher level wrappers around them for a neat interface

    Elysia i will vote for you, although even you do not seem to put too many features (which is would like to have).
    Features can always be added later, but the important thing is not to overdo it!
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  12. #87
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    The people here (most of them) have this mentality of generic solutions, a one for all cure, which is not always possible!
    When it's not possible, we don't do it. If it's possible, then why should we write the same thing multiple times?

    And tell me why we have for_each in C++ when the basic, and way more generalized for( ; ; ) loop is already there?
    Code reuse. Using for_each, I can combine partial bodies in interesting ways. I can't do that with a for loop.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  13. #88
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Elysia, i would like to see some specialized features inside string class, even when, there are generic options available!
    It would be better to state your reasoning than to state your support since this is not a popularity contest.

    The people here (most of them) have this mentality of generic solutions, a one for all cure, which is not always possible!
    Of course they are not always possible, or at least not possible while remaining efficient. I cited the case of std::sort versus std::list::sort as an example. As such, so what if they are not always possible within the given constraints?

    And tell me why we have for_each in C++ when the basic, and way more generalized for( ; ; ) loop is already there?
    for_each is not part of the C++ core language but it is part of the C++ standard library. The only benefit of for_each is in abstracting away the loop - if feasible the more appropriate generic algorithms should be used to better describe what is happening.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  14. #89
    Banned
    Join Date
    Nov 2007
    Posts
    678
    CornedBee, not to start a debate, poor Elysia's thread will be destroyed, just one thing:

    Useful generalization:
    Code:
    template <typename A>
    void sort(A *array, int n) {}
    Useless generalization:
    Code:
    template <typename A>
    A incrementByTwo(A v) { return A+2; }
    Now for the for_each, it is generalized, and will process every element, what if i wanted only every third element, or what if at element i, i need an element i - n ?

    for ( ; ; ) loops wins here, but that did not stop the developers from creating for_each, you also like it, for whatever reasons, that is my point, generalizations are there, but some specific utility stuff is always welcome!

    So do not force some one for g-e-n-e-r-a-l-i-z-a-t-i-o-n-s, who wants to add a simple convenient function to the class, that is a long word, and long work!

  15. #90
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    I'm going to have to side with everyone else here. The main reason I have this class and indeed, all my functions and libraries in general is due to code use.
    The more generic functions I can write, the better because it means less code to rewrite. The good thing is that we can write user-friendly interface functions to those generic functions. This allows for easy programming (though it may take a bit extra work to write those, but I'm fine with that) and if those functions does not do the trick, you can implement another function from the generic algorithm.

    It's also good learning to implement generic functions, I think.
    Don't worry. The generic functions won't make the class hard to use.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM
  2. Laptop Problem
    By Boomba in forum Tech Board
    Replies: 1
    Last Post: 03-07-2006, 06:24 PM
  3. implementation file
    By bejiz in forum C++ Programming
    Replies: 5
    Last Post: 11-28-2005, 01:59 AM
  4. Replies: 5
    Last Post: 11-07-2005, 11:34 PM
  5. Memory Problem - I think...
    By Unregistered in forum C Programming
    Replies: 4
    Last Post: 10-24-2001, 12:14 PM