If you want something truly efficient, you'll likely have to write your own storage and search. Try a google on search algorithms, there are a lot, and you'll need to pick the one that's best for you.
You also have the option of built-in structures to help you. You're using a List... I'm not sure what the code behind your search and retrieve is, but it's likely linear. My suggestion would be to try a
HashTable as they have very fast retrieval mechanisms.
However, you'll still have to keep track of the data intelligently. As Thlintoq said, you can safely ignore anything that's past what you're looking for. The hash table might help you group things... like, tasks that are all for a specific day (or half a day) could be stored in the same hash location, so when you search you just pick up the items that are reasonably close to what you're looking for. Then you would do a linear search on that particular group.
A pseudo-code example of what I'm trying to say...
- struct TaskStorageObject
-
{
-
string key;
-
List<Task> taskList;
-
}
-
-
HashTable taskStorage = new HashTable();
-
-
main method
-
{
-
...
-
Task myTask = new Task(<DateTime object for occurance>, <whatever>);
-
InsertTask(taskStorage, myTask);
-
}
-
-
InsertTask(HashTable taskStorage, Task taskToInsert)
-
{
-
string key = taskToInsert.TaskTime.Date.ToString(); // ie, "21-10-2009"
-
TaskStorageObject taskSet = taskStorage[key];
-
if (taskSet != null)
-
{
-
taskSet.taskList.Add(taskToInsert);
-
}
-
else
-
{
-
// create a task storage object, put your task in it, and put it in the hash table
-
}
-
}
Retrieval would be done in a similar way... you'd have a DateTime for what you're looking for so you'd get the TaskSet for the day and then perform a linear search on that to find the particular task.
You can break it down however you like though, I'm just trying to throw out suggestions. Between this and what Thlintoq wrote, hopefully you've got a few ideas now :)
(Does this seem reasonable or make sense?)