How do i convert a vector to a treeset?

Hi
I have a vector of objects which i need to pass to a new treeset.
How an I do it?
class ......
TreeSet ts = new TreeSet(theBranch.getVideoTable());
Class branch {
public Vector getVideoTable() {
// return the reference to the Vector holding the branch videos
}

Do you want to do something like
Comparator c = new Comparator( ){
   // implement the methods
   // compare and equals
TreeSet t = TreeSet(c) ;
t.addAll( yourVector ) ;and for Comparator
public int compare(Object o1,
                   Object o2)Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

Similar Messages

  • How do I convert a Vector to be passed into the session

    Hi I have a vector in a JSP that I need to pass on to a second JSP. I use the following command to do that just as I pass normal other strings:
    session.setAttribute("MyVector",vecData);
    But the follwoing error is been thrown by Tomcat.
    Incompatible type for method. Can't convert void to java.lang.Object.
    out.print(session.setAttribute("ResultsSet",set));
    ^
    I guess I have to convert it explicitly into an object and then how do I do that? could someone please help me fast on this?
    if this doesn't work is there some other way to send this vector to my other page? I am currently sending enough strings using the above method, but for Vectors it doesn't seem to work though I am told that a session object can carry any object unlike the request object that carries only strings. Please help!!!!

    Hi Calin thank you so much for taking ur time to help me with my problem.
    well let me explain my requirement fully in detail. JSP1 has a form on it for the user to fill in. its in the form of a table with multiple rows. say as in entering product details one after the other in an invoice.
    I want each of these rows taken in and passed into JSP2.
    What I do is pack each row of the table into a hashtable using a 'for' loop.
    Then I add each record (within the 'for' loop) to a Vector. After the 'for' loop, outside of it, I set this Vector to the session as :
    session.setAttribute("RecordSet",vecRecordSet);
    Well let me copy paste and extract of the coding from my source which shows what I have done.
    Vector set=new Vector();
    for (int i=0;i<Integer.parseInt(request.getParameter("NoOfRecords"));i++)
    Hashtable Record=new Hashtable();
                   Record.put("ReminderStatus",ReminderStatus);
                   Record.put("CustomerNo",CustomerNo);
                   Record.put("CustomerName",CustomerName);
                   Record.put("Address",address);
                   Record.put("ContractNo",ContractNo);
                   Record.put("MachineID",MachineID);
                   Record.put("ModelNo",ModelNo);
                   Record.put("Description",description);
                   Record.put("SerialNo",SerialNo);
                   Record.put("ContractValue",ContractValue);
                   Record.put("NoOfServices",NoOfServices);
                   Record.put("ContractStartDate",ContractStartDate);
                   Record.put("ContractEndDate",ContractEndDate);               set.add(Record);
         session.setAttribute("ResultsSet",set);//SHERVEEN
    well don't worry about the for loop condition up there cos it works for the main functionality that exists within the for loop. but what seems to go wrong is when I add records to the hashtable and when I pack it to the Vector "set"
    I hope I have not done something wrong as a principle over here.
    And btw the error that I showed u before, is pointed at a row which exists in the file that is generated when compiled. the out.println part is generated in that file during compilation and I don't know why.
    I hope I have given u information for u to make some sense of my requirement and thank u a million once again for ur effort to help me out. I am grateful to all of u.

  • Converting a Vector to array

    Hi,
    How can I convert a Vector to an array of int ?
    I tried this
    //v is an object of class Vector
    int [] res=(int [])v.toArray(new int[0]);but it doesn't work so I find another way:
    //v is a Vector
    int len=v.size();      
    int[] res=new int[len];         
    for (int count=0;count<len;count++)
    res[count]=Integer.valueOf(v.elementAt(count).toString());      this works but it's inefficient , I want to do the conversion in a single line of code (if possible)
    thanks

    The code that I've posted belongs to a simple function whose aim is to fill an array with
    all the prime numbers the are less than a given value.
    The function must return an array of int (int[]).Since I don't know how many primes I will find, I need a growable array, so I decided to use Vector.If there is a better way, please tell me.
    Here is the function prototype:
    /**returns all prime numbers that are less than max_value*/
    public int[] getPrimeNumbers(int max_value){
    //function's body
    }thank you in advance

  • How do I convert a pdf to vector in illustrator?

    how do I convert a pdf to vector in illustrator?

    The artwork in the PDF might already be a vector graphic.
    If not you need to trace it either automatically or manually

  • Need to convert to vector format.

    I have a document with pictures.  I need to convert it to vector format before sending to printer.  Not sure how to do it.  Using CS5.  Is converting to outlines the same? 

    It must be difficult to convert from illustrator into a vector format since no one has a specific answer.
    Soshagayle7,
    There is no automagic "conversion" from a raster image to a vector graphic. The artwork represented by a raster image can be redrawn as vector artwork.
    You can re-draw the artwork using the vector drawing tools in Illustrator or any similar program. You can even import the raster image and use it as a guide while "tracing" it with vector paths.
    Or (and this is where the all-too-common misconception about "conversion" comes in)...
    You can use the autotrace feature which exists in Illustrator or any similar program to try to automate the process of "tracing" the raster image with vector paths.
    Either way, you end up with what would more accurately be called a "reinterpretation" of the subject, not a "conversion" of the raster image in the sense of "converting" one file format to another.
    And that's the key. All that most current autotrace features (including the one in Illustrator) do is detect color differences between pixels of a raster image based upon a user-specified sensitivity setting, and then try to draw vector paths which follow along those detected differences. It's very much a garbage-in-garbage-out process.
    And even when the "in" is not garbage, there is no real intelligence involved. The kind of autotrace algorithms in Illustrator and programs like it have no shape-recognition intelligence. For example, in the case of a human face, the autotrace feature doesn't know that the eyes' pupils are round; it just detects a region of similarly-colored pixels and tries to draw a path around them. Similarly, in the case of a geometric logo that obvously (to a human) is supposed to contain a perfect circle, the autotrace feature doesn't "see a circle"; it doesn't go and get the Ellipse tool and draw a circle that fits, as any human would do. Again, it just tries to follow around the regions of similarly-colored pixels.
    But that sounds okay, right? Well think about it. Imagine turning the sensitivity of such an algorithm way up to the max. What's going to be the most accurate autotracing of a raster image? The mathematically "most accurate" result would be a perfect vector square for each and every pixel in the image. And the "vector advantage" of that would be absolutely nill. The resolution-independence reason for preferring vector paths would be rendered moot. Such a graphic would be entirely vector, but to absolutely no advantage regarding scaleability. (Thus my comment about the line drawn with a 1-pixel raster image.)
    So the reason you haven't received an answer to the "how do I convert" question is because the same thing has been explained in this forum countless times, and to answer it correctly really requires a lengthy explanation (like this one) that tries to clear up the too-common misconception that autotracing is some kind of magic bullet for "converting" a raster image into a vector graphic in some kind of mathematically accurate way that then yields all the advantages of properly drawn vector graphics.
    Autotracing is useful to those who understand when it's appropriate and why. But without seeing or at least knowing more about the actual raster image you are dealing with, advising whether it's appropriate in your case is nothing but a guess. Generally speaking, if the image in question is not already of high enough resolution at the size at which it will be printed, then it's probably also not of high enough resolution for good auto-tracing results. And if it is of sufficient resolution for the size at which it will be printed, then there's probably no reason it needs to be vector.
    Bottom line: There's a good reason why vector graphics are preferred. But that means properly-drawn vector graphics. The best way to "convert" your raster image to a vector graphic is to re-draw it using the vector tools. The sometimes-acceptable but often sub-standard "cheat" for doing it is to import the graphic and apply the autotrace feature (called LiveTrace in Illustrator). It's use is explained in the online help.
    Autotracing--the "conversoin" that such questions are almost always talking about--is not a lossless translation, like converting quarts to gallons or binary to hexidecimal. Entropy always rules. Anytime something is automatically "reprocessed" something is lost, not gained. You see that in everything from repainting a room over and over without removing the old paint, to taking photographs of photographs of photographs. Degradation occurs. You swap one kind of ugliness for another. That's autotracing when used inappropriately.
    The drawing tools exist for a reason. If you really need vector paths, you should probably draw them.
    JET

  • How do I convert a pdf file to photoshop?

    how do I convert a pdf file to photoshop?

    unless you understand what you're doing and why, opening .pdf in Photoshop is a very risky move
    because any vector objects, including fonts, will be pixelized (rastered at the chosen document ppi)
    this really sucks if the designer delivered a professionally packaged PDF with vector elements because the vector will not print vector sharp
    for example
    a moron at a print shop drags PDF business cards or posters into Photoshop and prints pixelized vector objects -- when you ask why the vector didn't print sharp -- they are clueless
    you also may hit profile issues that change the designer's color
    there must be 50 ways to ruin a project (and 25 of them are downstream)...

  • How do I replace one vector mask with another?

    I have a template for a web site that I'm trying to figure out as I learn CS5.  The template has a vector mask created out of some writing that was converted into an object/vector mask.  I would like to replace with a layer I created that has different writing in it.  How would I replace the vector mask in the template with the new object I created?
    Thanks for any help you can give.
    Best -- Catherine

    • In the Layers Panel draw the Layer’s Vector Mask icon onto the trashcan-icon
    • move that Layer above the new Text Layer
    • invoke Create Clipping Mask (command-alt-G) from Layers Panel’s fly-out menu or alt-click on the line separating the two Layers’ icons

  • How to properly convert ai files to PDF

    I have a several AI files that need to be converted to pdf. I now that I can just save as PDF under File, but the will save with current defaults.
    My files consist of vector images and photoshop images pds files.
    How do I convert to PDF with out losing quality but decresing the size, ready for online use (to download).

    >Turn off Optimize for Fast Web View,
    I don't know about that, have you had a bad experience with doing this?
    If you save in Acrobat 7 or 8 you can also reduce the files size by going to Document>Reduce Document Size, which eliminates things that are left from conversion but have nothing to do with output. Sometimes saves a lot of size sometimes just a small amount.

  • How to batch convert psd to png with layers

    how to batch convert psd to png with layers
    i want to convert lots of PSD files into PNGs WHILE RETAINING
    LAYERS!
    simply batching and choosing custom setting flattens the
    thing.
    how do i do that!??
    and i KNOW it can be done somehow - because i have some old
    png's i KNOW come from the same psd source. ironic, isn't it?
    besides - feature wish for adobe developers:
    A) batch conversion should include 300dpi to 72dpi and vise
    versa.
    B) batch conversion should include PSD to PNG and vice versa
    - including layers and transparency.
    C) RGB to CMYK option when converting from 72 dpi to 300dpi.
    D) batch exporting should include PNG32 which it doesnt now -
    but somehow DOES include the outdated and stupid gif-format.
    E) i'd like the Actions feature of photoshop - makes batching
    complicated procedures easly.
    F) I'd like support for the brushes of photoshop
    G) Better selecting tools for details like hair and fine
    edges.
    Important notes is that i as webdesigner often need to make
    certain aspects of my clients graphics into print material. Also
    that i use fireworks for picture editing.
    Praise for the developers of fireworks
    A) the compression facility of JPGs is AWESOME!
    B) PNG as fileformat is likewise awesome - i end up using it
    for almost all i do these days. Transparency and good file sizes. I
    have used fireworks cs3 to convert all psd and tiff and ai files to
    PNG.
    C) the vectors and styles and method of selecting and editing
    things in fireworks is FAR SUPERIOR to flash and photoshop!

    senocular wrote:
    > Save the following code in a .jsf file and run it in a
    batch. It will save
    > your batched PSDs in their original location as PNGs
    (using the same file name
    > with .png tacked on the end). You'll probably need to
    save the file in your
    > Fireworks/Configuration/Commands directory to allow the
    batch to pick it up.
    > Note that any save location you specify in the batch
    will be irrelevant. This
    > code just saves the files in their original location.
    >
    >
    >
    > var dom = fw.getDocumentDOM();
    > fw.saveDocumentCopyAs(dom,
    dom.filePathForRevert+".png");
    >
    Thanks Trevor!
    Jim Babbage - .:Community MX:. & .:Adobe Community
    Expert:.
    http://www.communityMX.com/
    CommunityMX - Free Resources:
    http://www.communitymx.com/free.cfm
    .:Adobe Community Expert for Fireworks:.
    Adobe Community Expert
    http://tinyurl.com/2a7dyp
    See my work on Flickr
    http://www.flickr.com/photos/jim_babbage/

  • How use SetIntArrayRegion with std::vector int ?

    I have a vector of ints that i want to put into a jintArray. How do I do this?
    When I tried the below code, it didn't work but instead when i printed out the int values on the java side, they were all messed up.
    jintArray arr = env->NewintArray( intVector.size() );
    env->SetintArrayRegion( arr, 0, intVector.size(), ( jint * ) &( intVector ) );This returns weird values. What am I doing wrong?

    This isn't a Java/JNI-specific issue. Your code also wouldn't work if you tried to do this:
    void foo( int* );
    void bar() {
        vector<int> a(10);
        foo( (int*)&a );
    }Hint: using a cast is a bad idea. It's wrong for the same reason the following code is wrong:
    void foo( double* );
    void bar() {
        double d = 42.0;
        foo( (int*)&d );
    }You can't just use a cast as a sledge-hammer and magically expect the right thing to happen. In your original code, you're passing the address of the C++ vector object as if it were the address of a plain old C-style array of int.
    Using old-style casts is a bad idea in general. This is why new-style casts were added to the language. Had you tried to use:
        static_cast<int*>( &intVector )the compiler would have correctly complained. Old-style casts assume you know what you're doing. In this case, your old-style cast is equivalent to a reinterpret_cast<int*>.
    That aside, there's intentionally no way to convert a vector<T> into the address of its first element because there's no guarantee that the implementation of vector will store array elements contiguously.

  • How can I convert on HDF file from HWS file?

    how can I convert on HDF file from HWS file?

    Well by opening up the HWS file with HDFView, it contains the below structure.  In the axis0 properties (time axis) there is a field called increment that is the sampling rate I used (5 nanoseconds).  But I do NOT see any additional info in terms of triggering modes or delays, etc.
    wfm_group0
    axes
    axis0
    axis1
    data_vector
    data (here is our data, I verified it is correct)
    id
    traces
    trace0 (we don't care about this, I think)
    vectors
    vector0
    data (not sure what the difference is between this and axis1
    wfm_group0 (1576, 2)
        Group size = 4
        Number of attributes = 5
            major_version = 2
            minor_version = 0
            release_version = 6
            type = NI-Waveform
            writer = NI-HWS
    axis0 (7424, 2)
        Group size = 0
        Number of attributes = 5
            implicit? = 1
            increment = 5.0E-9
            numDigits = 57
            ref_time = 0
            start = 0.0

  • I need to convert PDF file to Word Document, so it can be edited. But the recognizing text options do not have the language that I need. How I can convert the file in the desired of me language?

    I need to convert PDF file to Word Document, so it can be edited. But the recognizing text options do not have the language that I need. How I can convert the file in the desired of me language?

    The application Acrobat provides no language translation capability.
    If you localize the language for OS, MS Office applications, Acrobat, etc to the desired language try again.
    Alternative: transfer a copy of content into a web based translation service (Bing or Google provides a free service).
    Transfer the output into a word processing program that is localized to the appropriate language.
    Do cleanup.
    Be well...

  • How can I convert an int to a string?

    Hi
    How can I convert an int to a string?
    /ad87geao

    Here is some the code:
    public class GUI
        extends Applet {
      public GUI() { 
        lastValue = 5;
        String temp = Integer.toString(lastValue);
        System.out.println(temp);
        showText(temp);
      private void showText(final String text) {
        SwingUtilities.invokeLater(new Runnable() {
          public void run() {
            tArea2.setText(text + "\n");
    }

  • How can I convert an InputStream to a FileInputStream ???

    How can I convert an InputStream to a FileInputStream ???

    Thanks for you reply, however, I am still stuck.
    I am trying to convert my application (which runs smoothly) to a signed applet. The following is the original (application) code:
    private void loadConfig() {
    String fileName = "resources/groupconfig";
    File name = new File(fileName);
    if(name.isFile()) {
    try {
         ObjectInputStream in = new ObjectInputStream(new FileInputStream(fileName));
         pAndGConfig = (PAGroupsConfig)in.readObject();
         in.close();
         return;
    } catch(ClassNotFoundException e) {
         System.err.println("++ERROR: "+e);
    } catch(IOException e) {
         System.err.println("++ERROR: "+e);
    System.out.println("Can't find file: " + fileName);
    Because all code and resources now reside in a Jar file (for the signed applet), I must use the following line to access the resources:
    InputStream is = this.getClass().getResourceAsStream(fileName);
    I then need to convert the 'InputStream' to 'ObjectInputStream' or 'FileInputStream' so that I can work with it.
    I would be very grateful if you could help shed some light on the matter - Cobram

  • How can I convert an audio file (speech) into a text?

    Hello everybody!
      Can someone explain how I can convert a garageband file (voice speech) into a text? My Mac is a Mac OS X 10.5.8 version, so I don't have programs such as mountain Lion. I thought to use googlevoice. Is this option available? If yes, how can I use it?
    Thanks.

    Hello, I only find google voice available for Abdroid!?
    http://www.ehow.com/info_10033225_google-voice-system-requirements-android.html
    Some possibilitities, not sure if they have 10.5.8 compatble versions anymore...
    http://atmac.org/speech-to-text-dictation-software-for-os-x
    Some reviews of later Dragon Speak...
    http://www.finetunedmac.com/forums/ubbthreads.php?ubb=showflat&Number=22962

Maybe you are looking for