Re: Convert a string to a vector?

From: Andrew Thompson (SeeMySites_at_www.invalid)
Date: 02/17/04


Date: Tue, 17 Feb 2004 21:45:54 GMT

Nishi Bhonsle wrote:
....
> I have 2 vectors of 10 elements each and I needed to make a single
> vector out of them.

Why? What is the actual input you have
and the output you require?

It depends on why you ever had vectors,
they use much more resources than arrays.

>..So I converted both the vectors to strings using
> the toString() method of vector class and then used the concat()
> method of the String class to concatenate the strings.

If you want to end up with 20 elements in
a new data vector or array, converting them
to strings in the meantime is a terribly bad idea.

A better way is to create a single array/vector
as big as both, then simply loop through
each and add the elements to the final data
vector/array.

_However_

You need to direct your question over to..
http://groups.google.com.au/groups?group=comp.lang.java.help
where these sorts of questions are answered.

--
Andrew Thompson
* http://www.PhySci.org/ Open-source software suite
* http://www.PhySci.org/codes/ Web & IT Help
* http://www.1point1C.org/ Science & Technology


Relevant Pages

  • Re: substring finding problem!
    ... overlapping strings. ... dangerous because it finds overlapping strings, ... I do think that for the same reason your notion of "concat" ... strange things can happen outside programming, and programmers, even ...
    (comp.lang.c)
  • Re: TeamB, Borland, admit obvious
    ... > strings as using the Concat function: ... The plus operator is faster than Concat. ... > Microsoft has nothing to offer Visual Basic developers other than hack. ...
    (borland.public.delphi.non-technical)
  • String Concat vs. Plus operator
    ... Dumping the IL for TestStringOp reveals that this is converted to the ... the strings into it before finally calling the fast string allocator. ... concat is 4 or less. ... Understandably timing this code won't be very revealing since the optimizer ...
    (microsoft.public.dotnet.framework)
  • Re: String.Concat vs String.Format
    ... ramadu wrote: ... Using strings is part of every day life. ... Well, the Concat call is faster, *but* it's unlikely to ever be ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Convert a string to a vector?
    ... So I converted both the vectors to strings using the toString ... method of vector class and then used the concatmethod of the String class ... Instead of converting to Strings and back, can you not just do this? ... If you were storing characters in the strings, try using a for loop to ...
    (comp.lang.java.programmer)