CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: filtering data

  1. #1
    Join Date
    Nov 2006
    Posts
    37

    filtering data

    I have created a class Terminus with methods create a pile of buses which holds information like with busnum, company, dayorder, start time, places travelling. The dayorder of week is Sunday – 1, Monday – 2, … Saturday – 7.

    Now i need

    Method to filter records to select and view
    o dayorder wise particular place of travel
    o place of travel wise on any day listing the buses
    o place of travel, from time and to time

    I need help in starting with the filtering process b'coz i am still very unsure of how to do so..

  2. #2
    Join Date
    Dec 2005
    Posts
    251

    Re: filtering data

    You can do something as simple as this:
    Code:
    public List<Bus> filterByDay(List<Bus> list, int dayOfWeek)
    {
       //make new data structure to hold the filtered Bus instances
    
       //for each Bus in the list
          //if the Bus.getDayOfTheWeek is not equal to dayOfTheWeek
             //add a reference to it to the new list
           
       //return the new list
    }

  3. #3
    Join Date
    May 2006
    Location
    UK
    Posts
    4,473

    Re: filtering data

    From your brief outline it's not totally clear how your classes interrelate so apologies in advance if I've misunderstood your design but it appears that you have a terminus that has 'n' busses that each hold information on the route timetable (be that all routes or just the routes they do).

    Is this design correct? Should busses know about the list of routes they do and when they do them or should they just be assigned a route from the timetable to complete and on completion wait in a pool until they are assigned another route. In the first model if a bus breaks down you would lose that route until the bus is repaired whereas in the second model you are not reliant on any one bus to complete any particular route at any particular time. You just use the resources (busses) as they are needed or, in a time of shortage, when they become available.

    I need help in starting with the filtering process b'coz i am still very unsure of how to do so..
    You may also need to look at sorting the data to get it into the correct order.

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured