29 | | ^(Describe your design here.)^ |
| 29 | In order to get better performance without making huge refactoring (introduce new type, replace using old types with the new one etc.) two methods will be added to the ProList interface. Their implementation will be in BaseProList and this will keep other classes and their use with no change. |
| 30 | |
| 31 | A new field will be added to BaseProList - a Map instance where will be stored the elements from the list under some key. This doesn't remove the need from the list itself. Nothing of this will remove some existing code. Only new code will be added. |
| 32 | |
| 33 | A new class will be added - ListEntry. It will have two field - key : Obejct and value : Object. This class will serve as a helper class for work with the Map. |
| 34 | |
| 35 | In the add/remove method of ProList will be added new functionality that will add the parameter to the map with the following rules: |
| 36 | * If the parameter is ListEntry - the key in the map is the key of ListEntry |
| 37 | * if the parameter is Immutable - the key in the map is the Immutable object (its hashCode) |
| 38 | * if the parameter is Mutable - the added in the map is null |
| 39 | |
| 40 | The two new methods are : |
| 41 | * findAll (key : Object) : List<ListEntry> - this method will return all the entries in the list with the specified key |
| 42 | * findOne (key : Object) : ListEntry - this method will return only one entry from the list for the key. More - if there are more than one entry an exception will be thrown |
| 43 | |
| 44 | |