Data structure for new/old items codes
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Data structure for new/old items codes

  1. #1
    Join Date
    Dec 2012
    Posts
    2

    Data structure for new/old items codes

    Hello,

    I have a 2 tables

    items codes: new item code, old item code
    items quantities: item code, month, items quantity

    There are several cases:

    Case 1:
    Z is the newer code, X is older code
    X -> y -> Z

    Case 2:
    X -> Z
    Y-> Z
    Z is the newer code, X & Y are older code

    I need to recalculate quantities table.

    Case 1:

    replace Z quantity by X quantity + Y quantity + Z quantity
    replace Y quantity by X quantity + Y quantity

    Before update:
    x 10
    Y 20
    Z 30

    After update:
    x 10
    Y 10+20=30
    Z 10+20+30=60


    Case 2:

    replace Z quantity by X quantity + Y quantity + Z quantity

    Before update:
    x 10
    Y 20
    Z 30

    After update:
    x 10
    Y 20
    Z 10+20+30=60

    How can I create a data structure to store 'items codes' with something like pointers (new code to old code)
    so I will be able to find all the previous items codes of a selected item code ?

    Thank you for your help

  2. #2
    Join Date
    Feb 2011
    Location
    United States
    Posts
    1,000

    Re: Data structure for new/old items codes

    You probably want a hash table, also know as dictionary or associative array.
    Best Regards,

    BioPhysEngr
    http://blog.biophysengr.net
    --
    All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

  3. #3
    Join Date
    Dec 2012
    Posts
    2

    Re: Data structure for new/old items codes

    Hello,

    Thank you for your answer.

    Does hash table will be useful in this situation ?

    a-> b-> c -> d -> e
    f -> g -> h-> e
    i -> e

    I mean E is the current item code which replaces D,H,I.
    A-I are old names in 3 chains.
    I need to save for each letter (name) 12 numbers (demand for months).
    In order to calculate E demand I need to sum A-I demands and add it to E demand (Edemand=Ademand+Bdemand+Cdemnd+...+Idemand)

    What do you think ?

    Thank you for your help

Posting Permissions

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


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center