Reply: equals method

From: Darryl Woodford (dwoodf_at_essex.ac.uk)
Date: 11/18/03

  • Next message: Anthony Borla: "Re: Reply: equals method"
    Date: 17 Nov 2003 16:33:20 -0800
    
    

    **Firstly, apologies for posting this as a new thread. Waiting for
    Easynews to turn on posting as the Uni doesn't offer a news server,
    and having to post through google.**

    Anthony,

    Thanks for your suggestion.It certainly helped...

    On reading over your suggestion, I tried adding:

          for (int Counter = 0; Counter < 50000; Counter++) // Fill array
    to prevent Null Errors
          adic[Counter].word = new String();

    which resolved the original problem, I'd filled the array as a whole,
    but forgotten to fill the word part..but it is now throwing a
    java.lang.ArrayIndexOutOfBoundsException: 20 with the line

                            adic[i].links[cnttwo] = adic[cntone].links[0];

    which I guess is the second bit you were referring to..

    I tried rewriting as:

    --
    for (int i = 0; i < adic.length; i++) { // Take each member of arrays
    dictionary in turn
    	int cnttwo = 1; // Initialise second count variable, 1 as links[0]
    already filled
    	for (int cntone = 1; cntone < (adic.length - 1); cntone++) { // Take
    each member of arrays dictionary in turn
    		if (adic[i].word.equals(adic[cntone].word)) { // Compare against the
    word we're looking for
    			adic[i].links[cnttwo] = adic[cntone].links[0]; // If it matches,
    add it as next reference
    			//delete adic[cntone] // Delete anagram as repeat, now listed
    elsewhere and to prevent multiples
    			cnttwo++; // Increment reference by one
    		}
    	}
    }
    --
    So it should be comparing adic[0].word with adic[1].word, then storing
    in adic[0].links[1] if found, before comparing with adic[2].word,
    storing in adic[0].links[2] etc... up until the end of the array.
    .
    I was thinking this would prevent it going over the end of the array,
    but didn't have the desired effect... I'm sure I'm missing something
    simple..?
    Cheers,
    Darryl
    

  • Next message: Anthony Borla: "Re: Reply: equals method"

    Relevant Pages

    • Re: ADSI script for IIS 5.0 can not run in IIS 6.0
      ... The only way to determine "why" is for someone to look at the source code. ... This posting is provided "AS IS" with no warranties, and confers no rights. ... Problem fixed by changing the array for ServerBindings from dynamic array to ...
      (microsoft.public.inetserver.iis)
    • Re: A challenging file to parse
      ... Do the same thing, but when storing in an array, store it at ... Also the data format. ...
      (comp.lang.c)
    • Re: Serializing data vs Storing it in a seperate table
      ... and storing it in a single entry in a table or storing each element of ... Do some research on "database normalization". ... It really depends how big the array is and whether you ...
      (comp.lang.php)
    • Re: A challenging file to parse
      ... algorithm problem and found a Orun-time and Omemory solution, ... Do the same thing, but when storing in an array, store it at ...
      (comp.lang.c)
    • Resizing a structur array in C
      ... doubles but to storing mxArray* pointers. ... I tried to resize a structure array using the C ... not the size of a pointer. ...
      (comp.soft-sys.matlab)