/container for key-value pair class kvpair private key kprivate /constructors kvpair( nulle nullkvpair(key kvale evalk kvale eval/data member access functions public key key(return kpublic value(return efigure implementation for class representing key-value pair need some mechanism for extracting keys that is sufficiently general one approach is to require all record types to support some particular method that returns the key value for examplein java the comparable interface can be used to provide this effect unfortunatelythis approach does not work when the same record type is meant to be stored in multiple dictionarieseach keyed by different field of the record this is typical in database applications anothermore general approach is to supply class whose job is to extract the key from the record unfortunatelythis solution also does not work in all situationsbecause there are record types for which it is not possible to write key extraction method the fundamental issue is that the key value for record is not an intrinsic property of the record' classor of any field within the class the key for record is actually property of the context in which the record is used truly general alternative is to explicitly store the key associated with given recordas separate field in the dictionary that iseach entry in the dictionary will contain both record and its associated key such entries are known as keyvalue pairs it is typical that storing the key explicitly duplicates some field in the record howeverkeys tend to be much smaller than recordsso this additional one example of such situation occurs when we have collection of records that describe books in library one of the fields for such record might be list of subject keywordswhere the typical record stores few keywords our dictionary might be implemented as list of records sorted by keyword if book contains three keywordsit would appear three times on the listonce for each associated keyword howevergiven the recordthere is no simple way to determine which keyword on the keyword list triggered this appearance of the record thuswe cannot write function that extracts the key from such record