Hashtables and Vectors

Hi there !!!
Today I made some stuff but still a lot more needs to be done.
So first of all let me explain what is all about.
I have to make a hashtable that contains a String as a key and a vector as a value associated with that String.The following classes extend Relation (this is an interface)
Analogy,Cause and so on.
The instances have as fields DestinationID and SourceID .
The table sorts the instances as follows : the objects with the same SourceID are put in a vector that is mapped to that SourceID.There is a second table that does the same but for the DestinationID-s
The tables I have implemented recursively
Here is the code for one of them:
public class AnnotationThread1 {
    private Vector v = new Vector();
    private Hashtable h_sourceID = new Hashtable();
    private Hashtable h_destinationID = new Hashtable();
    private Vector leaves = new Vector();
/** Creates a new instance of AnnotationThread1 */
    public AnnotationThread1() {}
/** Creates the hashtable (recursively) the key is the SourceID and the
*value is a vector that contains all the nodes that have the same SourceID
    public Hashtable add(Relation r){
        String sourceID = r.getSourceID();
        Vector v = (Vector) h_sourceID.get(sourceID);
        //if the Vector is null we create a new one
         if (v == null) v = new Vector();
        //if we add the same node twice the second will be neglected
          if (!v.contains(r)){
           v.add(r);
           h_sourceID.put(sourceID,v);
      return h_sourceID;
    }Now i should also retrieve the so called leaves : here the ID -s that are not SourceID -s . (they are not parents so to say).I have done that for every single object (i chech whether the given Relation possesses a leaf or not) but still I can not come up with an idea how to retrieve all leaves and for example to have them in a vector .
Here is the code how I check if one ID is a leaf or not:
/** Asks if a given ID is a leaf or not(uses the add() method)
*@param Relation r
*@return false if the node does not have a leaf and true otherwise
    public boolean ifLeaf(Relation r){
      boolean ifleaf = false;
      String leaf = r.getDestinationID();
      if (!h_sourceID.containsKey(leaf)){ ifleaf = true; }
      return ifleaf;
    }If anyone has ideas I will be very glad.
The same problems I have with finding the root.
Thanks in advance...

OPS I forgot to mention how is the table actually created.Well in the main class i have something like:
public static void main(String args[]){
      AnnotationThread1 example = new AnnotationThread1();
      BackgroundInformation a = new BackgroundInformation(0.1f,0.3f,"a","b");
      example.add(a);
      Analogy b = new Analogy(0.2f,0.1f,"a","c");
      example.add(b);
      SupportArgument c = new SupportArgument(0.2f,0.1f,"b","d");
      example.add(c);The Strings are as mentioned the SourceID and the DestinationID.
for example after writing
System.out.printlnexample.add(c);I will get as an output(in NetBeans):
a=[collate.AnnotationThread.BackgroundInformation@1f12c4e,    collate.AnnotationThread.Analogy@93dee9]}

Similar Messages

  • HashTable and Vector

    when we will use hashTable and Vector..plz explain with example..

    well, the main difference is, that a vector is a simple set of objects, while a map (e.g. HashTable) maps values to keys.
    a simple example (not java specific as you can see) to make this transparent:
    "Adam",
    "Bert",
    "Cesar"
    would be a list, while a Map looks like this:
    "A" -> "Adam",
    "B" -> "Bert",
    "C" -> "Cesar"
    and with the key you can actually access the value, thus retrieving the object bound to "A" from the map will give you "Adam"

  • Hashtable or Vector to create Jtree ?Data from dtatbase.

    I want build JTree in JApplet .
    The JApplet is connecting to a database .
    As soon as data change ,JTree change.
    1.How can use hashtable or Vector to create Jtree ?
    the Hashtable's Data or Vector's Data from Database.
    2.How Japplet connect to a database and get data?

    1-How can use hashtable or Vector to create Jtree ?
    read JTree constrcutors in which u can use Vector for creating JTree like new JTree(myVector);
    and in this myVector u can store your own objects and override toString() method of that object (stored in Vector), but as my practice its not good.
    2.How Japplet connect to a database and get data?
    You have to make signed applet for connecting your applet with database , and sorry to say but ita a real pain in your -------------

  • Matching Raster and Vector RGB color in InDesign CS3.

    We print on a Durst Lambda RGB imaging device to photographic paper. All color management is done as an early bind (raster files are converted to the printer's color space and vector colors are chosen from a palette database). So basically the files must go through InDesign without any color change in raster or vector information. We have clients that require specific RGB builds for logo colors the are present in both their raster and vector files.
    Color Management is set to "North American General Purpose 2" with "RGB: Preserve Embedded Profiles" selected.
    1) The file is exported as a PDF 1.4, High Quality, PDF/X_None.
    2) The PDF was ripped on a Cheetah RIP (Jaws level 3) with no color management on.
    3) Solid raster colors such as 0-255-0 will reproduce as 0-255-1.
    4) The color differences between the raster and vector are usually 1-4 points.
    5) The vector is consistent as was input in the programit's only the raster that changes. When you are trying to match raster and vectors logo colors it is a killer.
    However, I can go into the InDesign (or Illustrator) color settings and turn color management off (This is our current workflow). In doing this the RGB working space uses the monitor profile and "color management policies" are set to OFF. With these settings the RGB raster and vector match. The problem with this work flow is two fold:
    1) We have other devices than our RGB Durst Lambda that can use the InDesign color managementVutek flat bed 3200 and grand format 3360.
    2) We have had many occurrences where the custom "color management off" settings have reverted back to the default "North American General Purpose 2"without any intervention.
    I have tried this with different RIP's with the same results.
    Does anyone have an idea to create a simple PDF workflow and keep the color information consistent?
    Program: InDesign CS3 5.0.2
    Platform: Mac OS 10.5.2
    Computer: G5 tower with 4 gigs of RAM

    I believe that setting is an old Illustrator setting that has been saved to effectively turn the color management off. The monitor profile effects the image displayedit doesn't effect the color transform.
    Anyway, the color management I want to use is the "North American General Purpose 2".
    To reiterate:
    The procedure:
    1) The file is exported as a PDF 1.4, High Quality, PDF/X_None.
    2) The PDF was ripped on a Cheetah RIP (Jaws level 3) with no color management on.
    The Problem:
    3) Solid raster colors such as 0-255-0 will reproduce as 0-255-1It changes from the original raster color placed in InDesign.
    4) The color differences between the raster and vector are usually 1-4 points.
    5) The vector is consistent as was input in the programit's only the raster that changes. When you are trying to match raster and vectors logo colors it is a killer.
    To summarize, the color of the raster file will change from the original that was place into the documenteven though nothing was selected in InDesign that would change the color (i.e. profile conversion to an output profile or a transparency effect used). The change is slightbut there.

  • Pdf and vector files will not open in Adobe Illustrator after Yosemite Update

    I updated my OS on recommendation from apple. Pdf and vector files will not open in adobe illustrator now. Am i using the latest OS?

    Linda Feltner wrote:
    > I cannot import or open vector files in Freehand 10. I
    just get large
    > Xs instead of the image. I have a MAC OS 10.3.9,
    Freehand 10. I'm
    > trying to import some small files that are either .ai or
    .eps files
    > (all are vector) that open fine in Illustrator 10 (so I
    know they
    > work), but I can't use them in that program. I've tried
    adjusting in
    > Freehand Preferences the 'convert editable EPS files" ,
    on and off. I
    > tried adjusting the 'Embed...." selection on and off.
    Can anyone tell
    > me what thing I'm doing wrong. I have two files, they
    are map
    > boundaries, that need to scale and adjust their color
    and line width
    > over an aerial map. This can't be difficult, but I must
    be
    > overlooking something. Many thanks in advance. Linda
    >
    Freehand can't convert EPS files into editable vectors. I
    usually run
    EPS files through Illustrator and then into Frehand. If you
    don't have
    Illustrator you can convert the EPS into a PDF and that
    Freehand will
    sometimes convert into editable vectors (though it does
    involve a lot
    more clean up than going through Illustrator.)

  • Jax-ws 2.1 - problems returning hashtable and hashmap

    Hi,
    We're developing a set of applications that communicate via web services.
    The company decided that to do this we should use jax-ws 2.1.
    Everything is going ok, its really easy to use, except for a web method that returns a java.util.Hashtable.
    In the endpoint there's no problem, it compiles and deploys to a tomcat 5.5 without a problem.
    The client can access the wsdl via url, download it and create the necessary files (we use netbeans 5.5 for this).
    We can invoke the method getConfig without a problem, but the object returned only has the java.lang.Object 's methods, not the java.util.Hastable 's .
    Endpoint:
    package xxx.cdc_pm_i;
    import java.util.Hashtable;
    import javax.jws.WebMethod;
    import javax.jws.WebParam;
    import javax.jws.WebService;
    import javax.xml.bind.annotation.*;
    @WebService()
    public class cdc_pm_i{
    @WebMethod
    public Hashtable getConfig() {
    Hashtable<String,String> config = new Hashtable<String,String>();
         config.put("1","1");
         config.put("2","2");
    return config;
    Client:
    try { // Call Web Service Operation
    xxx.CdcPmIService service = new xxx.cdc_pm_i.CdcPmIService();
    xxx.cdc_pm_i.CdcPmI port = service.getCdcPmIPort();
    // TODO process result here
    xxx.cdc_pm_i.Hashtable result = port.getConfig();
    } catch (Exception ex) {
         ex.printStackTrace();
    I'm fairly unexperienced in Web Services and i have no idea why this works for any kind of return object (as long as its serializable) and has this problem with hashtables and hashmaps.
    Any idea on how to solve this?
    Thanks in advance,
    Rui

    Didn't find the solution for this, but any object that contains an Object in its methods / attributes had the same problems, so i just built my own table that only supports Strings and the problem was solved.
    If anyone knows why i had this problem and wants to share a solution, please do so.

  • Error while using Enumeration and Vectors

    Hi all,
    I am new bee in java i am using enumeration and vectors in my JSP page,
    i want to get the values from JSP page using enumeration and store then in Vector, below is the code, its giving errors saying ArrayIndexoutofException
    pls help, thanx in advance.
              while ( enum.hasMoreElements() )
              String enumString = (String)enum.nextElement();
              String[] enumValue =request.getParameterValues(enumString);
              for(int n=0;n<=enumValue.length;n++)
              tempbean.dbRows.add(enumValue[n]);     //tempbean.dbRows is a vector,
    if I seperate the For block out of While loop then im getting cannot resolve enum variable, bcoz its declared in while loop, I cannot declare it out side of while loop because I dont know the perfect size of the array and it will change dynamically.
    pls help

    Thankyou ,
    It worked out,
    Thank you very much.

  • Raster and vector..Photoshop to Illustrator

    I created a logo in Photoshop (it is now a raster image), now need to enlarge it and have it printed on Tshirts and signs.  Can I transfer it to Illustrator making it a Vector file, or does it need to be created in Illustrator to be a Vector file?

    Kristi,
    The difference between raster and vector graphics is far more than just resolution dependence. That's just one aspect. Just as important--even moreso in textile screen printing--is that vector artwork is built from objects. This makes all the difference in the world wihen it comes to practical production needs for "logos" and for screen printing.
    For example: Okay, suppose the raster image of the "logo" is oversampled enough to avoid pixelation (which is actually less of an issue with screen printing) when enlarged to the size needed for the T-shirt. Someone's making a blunderbuss statement like  "you can then color separate it" isn't even beginning to think through the practical requirements of the reproduction process. Yes, you can print color separations from a raster image. But what kind of separations do you get? Assuming a CMYK or RGB raster image, you'll get halftone dots. Halftone dots are inherently problematic in screen printing. Most common screen printing assumes line art and spot color, not contone art separated to halftones.
    There are methods for creating raster artwork in Photoshop which will result in color separations suitable for spot color and screen printing separations, but it's far more involved than just designing in CMYK or RGB and then making some automagic "conversion." It requires just as much forethought and understanding of the process as building it correctly as vector artwork.
    To advise you correctly, one has to know more about the specific situation in question regarding the specific original artwork and the capabilities of the screen printing house re halftones and color separations.
    A similar set of considerations apply to signs (which you also mention.)
    Trust me: If your focus is "logos" destined for screen printing and/or signage, and you intend to make it your standard workflow to create the original artwork in Photoshop and then use Illustrator as some kind of automagic "conversion" utility when you think you need vector graphics--then you are very much barking up the wrong tree, and are creating untold problems for yourself before you even start.
    JET

  • Why do fonts and vector images look broken in Acrobat Pro (on retina display)

    I often get scared of doing something horribly wrong every time I export to PDF from Indesign CC. I know I didn't mess up but my scariness is the effect of the terrible graphic support in Acrobat when viewing the pdf's. Fonts and Vector images look broken and the look of fonts only gets better after zooming in at an incredible 6400% ! Are my preference settings in Acrobat wrong or is it because Acrobat doesn't support Retina yet?

    Moving this discussion to the Acrobat Installation & Update Issues forum.

  • Size restrictions on arrays and vectors

    Hi all!!!
    I want to know whether there is any restriction on maximum size of array and vectors.
    If I have thousands of records to be displayed on browser through JSP, can I initialise the arrays/vectors with that no.
    Whether it will have adverse effect on performance.
    Thanks in anticipation

    Array lists (and vectors) use an array as backing data store. And since array indices are ints, the maximum number of elements in an array list is Integer.MAX_VALUE (2 ^ 31 - 1).
    About the performance: if you know how many elements you are going to add (albeit not precisely), you can create the array list with an initial capacity. This will improve performance because a new array is created when an element is to be added but the capacity has been reached.
    Kind regards,
      Levi

  • Fireworks Text and Vectors Blurring

    I always have this issue to think about text and vector handling of adobe fireworks....Look at these images
    this text on the left has beeen compressed at jpeg settings of 80...and the other one at 90...text in the first image looks blurry and if zoomed in ,,one see some dark blurry shades or something....same is the case with the borders on the red rectange ....With the 90 compression...result is much better but image size increases a lot...Also there are times when the same shades appear around the edges of rectangles etc also...
    I read this article
    http://kb2.adobe.com/cps/217/d6f2172a.html.... so is it of any help in this regard?
    and text in photoshop at even 70 compression look better than in fireworks...Adobe claims to be using photoshop like text engine in fireworks cs4 but i am having this problem in cs4 version as well...I hope some gurus out here will help me out.

    What you're seeing has nothing to do with the article you linked to.
    JPEG stands for Joint Photographic Experts Group. The file format was designed for photographs or images where the luminance and color information varies slowly from one pixel to another. The compression technique represents the luminance and color information as a mathematical function, but it throws out the detail terms, according to the level of compression. The more compression/lower quality, the more detail representation is thrown out. This is why the format is called "lossy." You lose information when you save to this format. The less you compress an image (higher quality), the less information is lost, but the larger the file is. There's no one optimal compression level, each image must be optimized according to its own content.
    In CS4, Fireworks is using the Photoshop text engine, but this is not the same as the export engine.
    The design you have is not a photograph and the information does not vary slowly from one pixel to another in the essential areas. In fact, you have hard edges - around the text and at the borders. The JPEG compression scheme is not good at edges, unless you set the compression low/quality high.
    In general, a graphic (non-photographic) image, is better off as a .gif or .png. Given that you have a gradient background behind your text, you might try a PNG24. Be careful when you export that you don't use the same name as your Fireworks source file. (One tip I picked up from this forum is to name my working Fireworks documents with.fw.png and then use the plain .png for the flattened, exported files.)

  • How can i create a Matrix and vector in LV7.0?

    thanks a lot!

    By Matrix do you mean an m x n array, and vector a 1 x n array? If so, use Initialize Array.vi. There are lots of array manipulation vi's in the array function pallette.
    Tim

  • Passing a hashtable and retaining a copy?

    I'm a little unclear about how parameters work in Java. I have a hashtable that contains some data. It gets passed into another class via a set method. The other class (B) takes the original hashtable and assigns it to a static field.
    I"ll illustrate it better with some pseudocode:
    class ClassA
        // assume this gets populated at some point
        private static HashTable originalTable;
        void someMethod()
            ClassB.setTable(originalTable);
    class ClassB
        static HashTable myTable;
        public void setTable(Hashtable newTable)
            myTable = newTable;
    }I thought all objects in Java were pass by reference. So, wouldn't ClassB.myTable get affected by any changes to ClassA.originalTable? I tried to clear ClassA.originalTable, but noticed that ClassB.myTable was unaffected.
    Why is this?

    I'm still confused. If I clear originalTable in
    ClassA, then somewhere in ClassB I try to access
    myTable, shouldn't myTable also be cleared? When I
    do this however, its as if ClassB retained its own
    copy.Huh? Note how I post code that contradicts what you write, while you only
    make vague statements :-)
    import java.util.*;
    class ClassA {
        public static void main(String[] args) {
            originalTable = new HashMap < String, String > ();
            originalTable.put("1", "one");
            originalTable.put("2", "two");
            someMethod();
            System.out.println("originalTable = " + originalTable);
            System.out.println("myTable = " + ClassB.myTable);
            System.out.println("clearing originalTable...");
            originalTable.clear();
            System.out.println("originalTable = " + originalTable);
            System.out.println("myTable = " + ClassB.myTable);
        static Map < String, String > originalTable;
        static void someMethod() {
            ClassB.setTable(originalTable);
    class ClassB {
        static Map < String, String > myTable;
        static void setTable(Map < String, String > newTable) {
            myTable = newTable;
    }

  • Are Vector Integer and Vector String different types?

    Maybe I am missing something.
    Are Vector <String> and Vector <Integer> different types? Can I have to methods of the same name with arguments of these types? That would be the point of method overloading.
    Appearently not. The following code does not compile:
    import java.util.*;
    public class b {
            public static void doit(Vector <String> what) {
                    what.add(new String(""));
            public static void doit(Vector <Integer> what) {
                    what.add(new Integer(0));
    }$ javac -target 1.5 -source 1.5 b.java
    b.java:3: name clash: doit(java.util.Vector<java.lang.String>) and doit(java.util.Vector<java.lang.Integer>) have the same erasure
    public static void doit(Vector <String> what) {
    ^
    b.java:6: name clash: doit(java.util.Vector<java.lang.Integer>) and doit(java.util.Vector<java.lang.String>) have the same erasure
    public static void doit(Vector <Integer> what) {
    ^
    2 errors

    So it is not possible to have both methods in a class. Let us do instanceof instead.
    import java.util.*;
    public class b {
            public static void doit(Vector what) {
                            if (what instanceof Vector<String>) {
                                   what.add(new String(""));
                            else if (what instanceof Vector<Integer>) {
                                   what.add(new Integer(0));
    }javac -target 1.5 -source 1.5 b.java
    b.java:4: illegal generic type for instanceof
    if (what instanceof Vector<String>) {
    ^
    b.java:7: illegal generic type for instanceof
    else if (what instanceof Vector<Integer>) {

  • Bitmap and vector like Photoshop?

    I am new to Fireworks and have worked with Photoshop. Photoshop is primarily a bitmap program, though you can work with vector graphics in it like you can in Fireworks. How does Fireworks work with both bitmap and vectors differently than Photoshop? Is it the same idea or is there a big difference with the way it handles this?
    Thanks.

    IMO Fireworks outshines PS in vector handling. In terms of the Pen tool, things are probably quite similar, but if you're creating vector shapes (custom or prebuilt) FW is a lot easier to work with.

Maybe you are looking for