AT&T Home | AT&T Labs | Research
AT&T Labs, Inc. - Research

The Yoix® Scripting Language

Home | What's New | Grammar | Documentation | Download | License | YChart | YDAT | YWAIT | Byzgraf | FAQs
hashIndex (String name, Pointer dest [, int defined]) yoix.util
 
Returns the index where name belongs in dest, which often is a Dictionary, or -1 if there is no definition of name in dest and there is no room for a new definition. If the optional defined argument is non-zero then hashIndex will return -1 whenever name is not currently defined in dest, even if there is room for a new definition.
 
 Example:   The program
import yoix.*.*;

Dictionary item[15] = {
    String id = "Lounge Chair";
    int    count = 100;
    double price = 123.50;
};

index = hashIndex("id", item);
printf("%s\n", item[index]);

printf("  id is stored at index %d\n", hashIndex("id", item));
printf("  count is stored at index %d\n", hashIndex("count", item));
printf("  price is stored at index %d\n", hashIndex("price", item));

if (hashIndex("supplier", item, true) < 0) {
    printf("=== supplier is not currently defined===\n");
    item.supplier = "unknown";
}

printf("  supplier is now stored at index %d\n", hashIndex("supplier", item));
uses hashIndex to locate elements defined in a dictionary and prints
Lounge Chair
  id is stored at index 10
  count is stored at index 13
  price is stored at index 6
=== supplier is not currently defined===
  supplier is now stored at index 11
on standard output.
 
 Return:   int
 
 See Also:   indexOf, indexOfObject, lastIndexOf, lastIndexOfObject

 

Yoix is a registered trademark of AT&T Inc.