Add utilities for merging dictionaries and deduplicating lists of items.
Review Request #11217 — Created Oct. 13, 2020 and submitted — Latest diff uploaded
This introduces a couple of new datastructure-related utility functions
that will be used in some upcoming changes.
filter_dup_list_items()
takes a list of items and filters out any
duplicates, ensuring that there is one of each instance in the list.
This is similar to passing a list intoset()
, but preserves the order.
merge_dicts()
merges two dictionaries together. Its approach is
simplistic but sufficient for our needs. Keys present only in the source
dictionary are placed in the destination. Lists are concatenated.
Dictionaries are recursively merged. Anything else triggers an error.Unit tests and doc generation were added for these new functions.
Unit tests pass.
Tested these in upcoming changes.