Move Infinate value to a vector

This is a discussion on Move Infinate value to a vector within the C++ Programming forums, part of the General Programming Boards category; Hello; I have a vector : Code: vector<string> word_vector; I need to do the following(or equivallent) Code: word_vector.push_back(an infinate value); ...

  1. #1
    Registered User
    Join Date
    Sep 2005
    Posts
    85

    Move Infinate value to a vector

    Hello;

    I have a vector :
    Code:
    vector<string> word_vector;
    I need to do the following(or equivallent)
    Code:
    word_vector.push_back(an infinate value);

    someone please help!

  2. #2
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,801
    What do you mean by "infinite value"? Do you mean you want to push back an infinitely large string? If so then the biggest a string can possibly be is equivalent to the value returned from the max_size member function.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  3. #3
    Registered User
    Join Date
    Sep 2005
    Posts
    85
    no, I am doing the mergesort, the inplace merge and I need a value that will never be changed by the sort

  4. #4
    Registered User
    Join Date
    Sep 2005
    Posts
    85
    If you could give me a different algo for the merge with a vector of strings I could use that too --- instead of the above question

  5. #5
    aoeuhtns
    Join Date
    Jul 2005
    Posts
    581
    A "different" algo? How can you get a different algorithm if nobody has seen your current one?

    You should not be needing infinite values on the ends of your vectors for merging. I know why you want one -- you need to use a special check to see if you've reached the end of the vector.

  6. #6
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    How can you push an infinite value when it is infinite? That makes no sense.

    The size of a vector can be retrieved by calling vector::size().

  7. #7
    Bioport Productions
    Join Date
    Oct 2005
    Posts
    215
    The highest value on a 32 bit platform is 64 bits long - via long, you will have to work out the math. Even on a 64 bit platform, the highest value is 64 bits, I doubt you will ever need the value to go past that to be honest, so consider it infinite
    -"What we wish, we readily believe, and what we ourselves think, we imagine others think also."
    PHP Code:
    sadf 

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. can some one please tell me the cause of the error ?
    By broli86 in forum C Programming
    Replies: 8
    Last Post: 06-26-2008, 08:36 PM
  2. syntax help?
    By scoobygoo in forum C++ Programming
    Replies: 1
    Last Post: 08-07-2007, 10:38 AM
  3. Vector class
    By Desolation in forum C++ Programming
    Replies: 2
    Last Post: 05-12-2007, 05:44 PM
  4. Need some help/advise for Public/Private classes
    By nirali35 in forum C++ Programming
    Replies: 8
    Last Post: 09-23-2006, 12:34 PM
  5. Certain functions
    By Lurker in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2003, 12:26 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21