Thread: Cost of dict

  1. #1
    Registered User
    Join Date
    Jun 2009
    Posts
    21

    Question Cost of dict

    Hi,

    I'm looking at initialising around 5 dictionaries in a class, intended to store DateTime.now as keys, and then the vaule of some action.

    The original class itself will also be stored in a dictionary, with up to 100 other instances of that class.

    Will this have any serious implications in terms of overhead / speed in the long haul?

    Thanks.

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    100 objects isn't that much unless you store many megabytes in them.
    Having a System.DateTime as a key in a dictionary sounds odd though, since System.DateTime.Now returns at least millisecond precision (probability of a successfull lookup is minimal).
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  3. #3
    Registered User
    Join Date
    Jun 2009
    Posts
    21
    Thanks,

    In the scope of the system the DateTime should always be unique, since it would be impossible to call the same method on the same object within a one second timeframe.

    I will consider changing this in the future though

  4. #4
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Then why use a Dictionary? Shouldn't a List or SortedList be more suitable?
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  5. #5
    Registered User
    Join Date
    Jun 2009
    Posts
    21
    Quote Originally Posted by Magos View Post
    SortedList be more suitable?
    agreed

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. what's the hidden cost of creating object?
    By kypronite in forum C++ Programming
    Replies: 13
    Last Post: 10-12-2008, 04:41 PM
  2. Cost of programming
    By swgh in forum A Brief History of Cprogramming.com
    Replies: 30
    Last Post: 05-28-2008, 09:36 AM
  3. structural fault any ideas
    By kaijuu in forum C Programming
    Replies: 17
    Last Post: 04-17-2007, 02:43 PM
  4. Binary Search Tree Cost of Path
    By indi_kila in forum C++ Programming
    Replies: 1
    Last Post: 04-30-2006, 08:20 PM
  5. Changing double time to double cost
    By chrismax2 in forum C++ Programming
    Replies: 2
    Last Post: 04-24-2004, 10:29 AM