How to implement my array/collection

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Maddy

    How to implement my array/collection

    Hi, I have just migrated to C#. I need some advice on the following
    problem:
    I need to create an object/structure with characteristics A,B and C. A
    and B are Integers while C consists of 2 Integers. I need to store
    data in these, every 5 sec or so, each value with a DateTime stamp/
    index. I will need a method to write the value with the DateTime.
    Another method to get the value for a specific DateTime. However, for
    getting the value, there might not be a corresponding DateTime index.
    In that case, the value closes to that time should be provided. What
    is the best method of implementing this? I would require ten instances
    of this object at any time. PLease advice.
    Thanks
    Maddy
  • Maddy

    #2
    Re: How to implement my array/collection

    Thanks for the ideas. Few things however-
    When I said only 10 objects, I meant the entire object. A,B and C
    would have about 400 to 500 values. Would have so many values in
    memory slow down the app? Should I save them more often to a file?
    Secondly each A, B and C need an individual timestamp.


    Comment

    • Marc Gravell

      #3
      Re: How to implement my array/collection

      On 20 Mar, 02:28, Maddy <mniti...@gmail .comwrote:
      Thanks for the ideas. Few things however-
      When I said only 10 objects, I meant the entire object. A,B and C
      would have about 400 to 500 values. Would have so many values in
      memory slow down the app? Should I save them more often to a file?
      Secondly each A, B and C need an individual timestamp.
      OK - can I just double check what you are describing? In terms of a
      visualisation, do you mean:

      SomeList [~10 of]
      "A"s
      int, timstamp pair [~500 of]
      "B"s
      int, timestamp pair [~500 of]
      "C"s
      int,int,timesta mp triple [~500 of]
      or do you mean:

      SomeList [~10 of]
      Items [~500 of]
      timestamp, int "A", int "B", {int/int} "C"
      - i.e. are A/B/C timstamped separately, or is it each combination of
      an A,B & C that is timstamped.

      Also 500 is not a big number. I wouldn't worry about memory - but how
      often do you need to seach it for a value (by date)? knowing that
      might help pick the most suitable structure. If it is infrequent (i.e.
      5s, the only timing in your post) then I wouldn't get excited, and
      would just use a List search (as already posted). [In any event, keep
      the data in timestamp sequence]
      If it is more frequent than this, then perhaps a binary search - or if
      you know the data is coming in at regular intervals (every 5s) you
      could use interpolation of the query value between the start/end
      values to find a first guess and then hunt from here.

      Let me know how often you search and I'll try to knock an example
      together...

      Marc

      Comment

      • Marc Gravell

        #4
        Re: How to implement my array/collection

        To be honest, if you are thinking of using disk storage, and the rate
        is only every 5-10s, why not just pump everything into a database and
        use SQL to do it? It would be a lot simpler, and you wouldn't have to
        worry about the difference between in memory and persisted. SQL
        Express is free and more than up to this - blus LINQ-to-SQL should be
        able to cope with expressions like the one in my early posts.

        I still don't really understand the A/B/C mapping...

        Marc

        Comment

        • Marc Gravell

          #5
          Re: How to implement my array/collection

          I'll re-read on Tuesday (long weekend) - but in real terms I would
          consider "install SQL Express" a very simple option...

          Comment

          Working...