A MergedItem is an element of an aggregate MergedList. The class derives from InputItem and inherits all its member variables and functions.
Implementation files
The MergedItem class is defined in the src/MergedItem.h header file; its member functions are implemented in src/MergedItem.cpp.
Technical Details
MergedItem maintains an array of Ranking objects that store the individual rankings (and scores) of the element in each preference InputList. Notice that the number of elements of this array (num_alloc_rankings) is always equal to the number of the input preference lists. In case the associated InputItem has not been ranked by a preference list (i.e. it is not included in the list), then its corresponding ranking in the Rankings array is set equal to NOT_RANKED_ITEM_RANK (defined in flagr.cpp). The actual number of the input preference lists that include a particular MergedItem is stored in the num_rankings member variable. This approach consumes more memory, but enables \(O(1)\) constant search times of the ranking of a particular item on a particular InputList.
The class also includes a self-class next pointer that points to another MergedItem object. This allows the storage of a collection of MergedItems in dynamic data structures, e.g. linked lists. Such structures are employed in MergedList, where MergedItems are stored in a hash table with linked lists as chains.
The following interactive block diagram depicts the functionality of the MergedItem class inside the entire architecture of FLAGR.
