Time for action – finding the most sought-after item
The local departmental store wants to start a dynamic display system that will show high-in-demand items in each of its departments. It has a rather social impact. People shopping trust fellow shoppers more than advertisements; so, they want to know what others are buying or looking at.
In this example, we will create a generic data structure that can keep track of elements and their sale count very efficiently. At any point in time, this data structure can be queried about the top n (user can decide the value of n) items in demand. On demand, it can show how many times an item was in demand in constant time:
- Create a class library project. Name it
MyDS
and change the name ofClass1
toMTFList ...
Get .NET 4.0 Generics now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.