• <GetStart>
  • CSPro User's Guide
    • The CSPro System
    • Data Dictionary Module
    • The CSPro Language
    • Data Entry Module
    • Batch Editing Applications
    • Tabulation Applications
    • Data Sources
    • CSPro Statements and Functions
      • Statement Format Symbols
      • Alphabetical List of Functions and Statements
      • List of Reserved Words
      • Deprecated Features
      • Declaration Statements
      • Symbol Functions
      • Item Functions
      • Array Object
      • Audio Object
      • Barcode and QR Codes
      • Case Object
      • Document Object
      • File Object
      • Freq Object
      • Geometry Object
      • HashMap Object
        • HashMap Statement
        • HashMap.getKeys Function
        • HashMap.contains Function
        • HashMap.length Function
        • HashMap.remove Function
        • HashMap.clear Function
      • Image Object
      • List Object
      • Map Object
      • Path
      • Pff Object
      • SystemApp Object
      • ValueSet Object
      • Program Control Statements
      • Assignment Statements
      • Data Entry Statements and Functions
      • Batch Edit Statements
      • Numeric Functions
      • String Functions
      • Multiple Occurrence Functions
      • General Functions
      • Date and Time Functions
      • External File Functions
      • Synchronization Functions
    • Templated Reporting System
    • HTML and JavaScript Integration
    • Action Invoker
    • Appendix
  • <CSEntry>
  • <CSBatch>
  • <CSTab>
  • <DataViewer>
  • <TextView>
  • <TblView>
  • <CSFreq>
  • <CSDeploy>
  • <CSPack>
  • <CSDiff>
  • <CSConcat>
  • <Excel2CSPro>
  • <CSExport>
  • <CSIndex>
  • <CSReFmt>
  • <CSSort>
  • <ParadataConcat>
  • <ParadataViewer>
  • <CSCode>
  • <CSDocument>
  • <CSView>
  • <CSWeb>

HashMap.length Function

Format
i = hashmap_name.length(ʃkey_value1, ..., key_valueNʅ);
Description
The HashMap.length function returns the number of keys at a specific location in the HashMap. Each key_value argument must be a numeric or string expression matching the type specified when declaring the HashMap. If no arguments are provided, the number of first-dimension keys is returned; if one argument is provided, the number of second-dimension keys is returned; and so on.
Return Value
The function returns the number of keys or 0 if no keys exist at the specified location.
Example
HashMap two_dimensional_hashmap(all, numeric);

two_dimensional_hashmap(
"A", 9) = 1;
two_dimensional_hashmap(
"A", 8) = 1;
two_dimensional_hashmap(
"A", 7) = 1;
two_dimensional_hashmap(
100, 6) = 1;

errmsg("%d", two_dimensional_hashmap.length());    // 2 (keys "A" and 100)
errmsg("%d", two_dimensional_hashmap.length("A")); // 3 (keys 9, 8, and 7)
errmsg("%d", two_dimensional_hashmap.length(100)); // 1 (key 6)

two_dimensional_hashmap.
remove("A", 9);

errmsg("%d", two_dimensional_hashmap.length());    // 2 (keys "A" and 100)
errmsg("%d", two_dimensional_hashmap.length("A")); // 2 (keys 8 and 7)
errmsg("%d", two_dimensional_hashmap.length(100)); // 1 (key 6)

two_dimensional_hashmap.
remove("A");

errmsg("%d", two_dimensional_hashmap.length());    // 1 (key 100)
errmsg("%d", two_dimensional_hashmap.length("A")); // 0 (no keys)
errmsg("%d", two_dimensional_hashmap.length(100)); // 1 (key 6)
See also: HashMap Object, HashMap.contains Function, HashMap.getKeys Function