Results 1 to 5 of 5

Thread: TreeMaps

  1. #1
    DavidG24 is offline Member
    Join Date
    Apr 2009
    Posts
    49
    Rep Power
    0

    Default TreeMaps

    Hey guys,

    I was just wondering if there was a Concrete Class implementation (and or a modification that can be made of the TreeMap class) so that it can only contain a fixed number of 'keys' ?

    Cheers,

    David

  2. #2
    OrangeDog's Avatar
    OrangeDog is offline Senior Member
    Join Date
    Jan 2009
    Location
    Cambridge, UK
    Posts
    838
    Rep Power
    6

    Default

    Simple modification using size()
    Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
    How To Ask Questions The Smart Way

  3. #3
    DavidG24 is offline Member
    Join Date
    Apr 2009
    Posts
    49
    Rep Power
    0

    Default

    Hey OrangeDog,

    please correct me if I am wrong, but doesn't the size method simply return the number of keys in the TreeMap, I'm hoping to ensure that the a set value for the number of keys is imposed.

    Thanks for your response.

    David

    ps - I guess a simple, modification to the add method could be used,
    if( mytreemap.size == mydesignatednumber)
    //do not add

  4. #4
    OrangeDog's Avatar
    OrangeDog is offline Senior Member
    Join Date
    Jan 2009
    Location
    Cambridge, UK
    Posts
    838
    Rep Power
    6

    Default

    Your p.s. is exactly what i was referring to, but use >= instead of ==

    Your choice whether to use delegation or inheritance.
    Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
    How To Ask Questions The Smart Way

  5. #5
    DavidG24 is offline Member
    Join Date
    Apr 2009
    Posts
    49
    Rep Power
    0

    Default

    [SOLVED]
    Hey OrangeDog, yeah I assumed as much.

    Thanks for the advice,

    David

Posting Permissions

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