Page 2 of 2 FirstFirst 12
Results 21 to 22 of 22
  1. #21
    moaxjlou is offline Member
    Join Date
    Oct 2008
    Posts
    23
    Rep Power
    0

    Default

    use an array of boolean with the number as an index to test/set number has been used
    Can you clarify on that a bit further?
    Thanks

  2. #22
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,559
    Rep Power
    25

    Default

    Say the ids range from 1 to 100. (you could rebase them to 0 to 99)
    Java Code:
    final int MaxId = 100;  // Define largest possible id
    ...
    boolean[] idsFound = new boolean[MaxId+1]; // +1 for zero based
    
    //Then when you get an id - see if used
    
    if(!idsFound[id]) {  // test if this id has been found/used
       idsFound[id] = true;  // remember this one is used
    }else {
      // this one already found/used
    }

Page 2 of 2 FirstFirst 12

Similar Threads

  1. [SOLVED] More RegEx help
    By JT4NK3D in forum New To Java
    Replies: 2
    Last Post: 05-23-2008, 04:07 AM
  2. Regex for file extension
    By gapper in forum New To Java
    Replies: 1
    Last Post: 01-31-2008, 03:59 PM
  3. Regex Quantifiers Example
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-10-2008, 10:44 AM
  4. Regex pattern
    By ravian in forum New To Java
    Replies: 4
    Last Post: 12-11-2007, 10:20 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •