Search:

Type: Posts; User: waltershc

Search: Search took 0.11 seconds.

  1. Replies
    42
    Views
    2,685

    Re: Presumably simple fix sets/maps

    There is currently no point in my code that saves an item for checking. How would I save the value itr.next() prints? I cannot make some integer variable and just assign it to equal itr.next() as...
  2. Replies
    42
    Views
    2,685

    Re: Presumably simple fix sets/maps

    I have tried various forms of that


    //local occurance variable
    int occurance = 1;
    String check = "";
    //System.out.println("pE entry=" + entry.getValue().toString());

    //print the...
  3. Replies
    42
    Views
    2,685

    Re: Presumably simple fix sets/maps

    Unfortunately not. It is still printing out the second 3 for mouse.
  4. Replies
    42
    Views
    2,685

    Re: Presumably simple fix sets/maps

    Output:
    wordMap=[cat=[2], mouse=[3, 3], phone=[4, 5], string=[1]]
    pE entry=[2]
    ID: [cat] Lines: 2 Occurance: [1]
    pE entry=[3, 3]
    ID: [mouse] Lines: 3, 3 Occurance: [2]
    pE entry=[4, 5]...
  5. Replies
    42
    Views
    2,685

    Re: Presumably simple fix sets/maps

    So you are saying what needs to be inserted into the linked list needs to be a string including the line number instead of an integer? ...Or are we just talking about output for debugging purposes?
  6. Replies
    42
    Views
    2,685

    Re: Presumably simple fix sets/maps

    What is your suggestion? I must be missing the point. I do not see how my printout is different from yours except for the concatenation of "wordMap=" and "pE entry=".
  7. Replies
    42
    Views
    2,685

    Re: Presumably simple fix sets/maps

    wordmap is line 2. the values for each entry are above their respective entries.
    Running.
    [cat=[2], mouse=[3, 3], phone=[4, 5], string=[1]]
    [2]
    ID: cat Lines: 2 Occurance: 1
    [3, 3]
    ID:...
  8. Replies
    42
    Views
    2,685

    Re: Presumably simple fix sets/maps

    I want to compare the objects(ints aka line numbers) in the linked list that are stored in the value location on the TreeMap.
  9. Replies
    42
    Views
    2,685

    Re: Presumably simple fix sets/maps

    The linkedlist's line values.
  10. Replies
    42
    Views
    2,685

    Re: Presumably simple fix sets/maps

    public static void printEntry(Map.Entry entry){

    //local occurance variable
    int occurance = 1;
    System.out.println(entry.getValue().toString());

    //print the word and the line numbers...
  11. Replies
    42
    Views
    2,685

    Re: Presumably simple fix sets/maps

    //Name: Hal Walters
    //Class: SCSC 321
    //Date: 3/10/2013

    import java.io.IOException;
    import java.io.BufferedReader;
    import java.io.FileReader;
    import java.util.*;

    public class driver1 {
  12. Replies
    42
    Views
    2,685

    Re: Presumably simple fix sets/maps

    //Name: Hal Walters
    //Class: SCSC 321
    //Date: 3/10/2013

    import java.io.IOException;
    import java.io.BufferedReader;
    import java.io.FileReader;
    import java.util.*;

    public class driver1 {
  13. Replies
    42
    Views
    2,685

    Re: Presumably simple fix sets/maps

    Forgive my ignorance, but where? There is a hasNext() call on line 49 when it runs through the iterator to call the printEntry method.
  14. Replies
    42
    Views
    2,685

    Re: Presumably simple fix sets/maps

    So get rid of the elseif statement and put something in around the while loop at the bottom of the main class?
  15. Replies
    42
    Views
    2,685

    Re: Presumably simple fix sets/maps

    Running.
    Exception in thread "main" java.util.NoSuchElementException
    at java.util.LinkedList$ListItr.next(Unknown Source)
    at driver1.printEntry(driver1.java:67)
    at...
  16. Replies
    42
    Views
    2,685

    Re: Presumably simple fix sets/maps

    http://i110.photobucket.com/albums/n92/dcmystery21/Untitled-1.png

    Thanks for the help so far. Let me know if you cannot read the text.
  17. Replies
    42
    Views
    2,685

    Re: Presumably simple fix sets/maps

    //Read the words and add them to the wordMap
    for (int lineNum = 1; (oneLine = inFile.readLine()) != null; lineNum++){
    StringTokenizer st = new StringTokenizer(oneLine);
    while...
  18. Replies
    42
    Views
    2,685

    Re: Presumably simple fix sets/maps

    Not for a single identifier. In other words, any given line number should not appear more than once on a line in the console.

    --- Update ---



    I played around with that a little bit but...
  19. Replies
    42
    Views
    2,685

    Re: Presumably simple fix sets/maps

    if (itr.toString() != itr.next().toString()){
    System.out.print(", " + itr.next());
    occurance++;
    }
    else{
    return;
    }


    well, i know this much already doesn't work. It should...
  20. Replies
    42
    Views
    2,685

    Re: Presumably simple fix sets/maps

    I updated the first post.

    Edit- Also went back and messed around with my code more and got it to a point where I feel it is even closer. I also added some code for formatting and counting word...
  21. Replies
    42
    Views
    2,685

    Presumably simple fix sets/maps

    I have made a good bit of progress with my code and am now stuck on something I believe to be quite simple. I have it printing out the line numbers that the word occurs on in the supplied text file...
Results 1 to 21 of 22