Collection Maps

A map groups key-value pairs in sorted order where all the keys are unique. The key and value can each be any data type. Maps are also known as dictionaries because the key is used to look up a value. Inserting a key-value pair into a map either adds the pair to the map or replaces the existing value of the associated key with the new value in the map, depending on whether the key already exists in the map.

Key
Value
Entry—A pair of associated key and value
Size—Number of entries in the map
Wires of map—Wire color matches the data type color of the value

While variant attributes can also be used as a dictionary to look up a value, maps are more flexible than variant attributes in that the key and value can each be any LabVIEW data type. For variant attributes, the key must be a string and the value must be a variant. Maps are also less error prone than variant attributes. For maps, LabVIEW returns wiring errors at edit time because the value accepts a specific data type. For variant attributes, LabVIEW returns wiring errors at run time because the value is a variant type that accepts any data.

Use the Collection VIs and functions and the collection controls and indicators to create or manipulate collections.

Note You cannot modify the embedded data in a collection interactively or programmatically. You can update collection data only as a whole through operations such as writing to the collection front panel terminal or right-clicking the collection and selecting Data Operations»Copy Data or Data Operations»Paste Data.

Refer to the following VIs or projects for an example of manipulating data using collections:

  • labview\examples\Collections\Set Collection - Word Counting.vi
  • labview\examples\Collections\Map Collection - Comparing Test Results.vi
  • labview\examples\Collections\Map Collection - Word Counting.vi
  • labview\examples\Design Patterns\Registration Map\Registration Map Usage.lvproj