The IDL_Container::Equals function method tests the value of each item in a container against an input value and returns true (1) if the specified item is equal to that value, or false (0) otherwise.
Note: The IDL_Container::Equals method is only available for containers of pointers. If you try to use the method on a container of objects then an error will be issued.
Example
p = IDL_Container()
FOR i=0,99 DO p.Add, PTR_NEW(FIX(RANDOMU(seed)*10))
match = p.Equals(5)
PRINT, WHERE(match)
IDL prints:
0 26 37 42 46 47 52 54 58 77 93 97
Syntax
Result = Obj->[IDL_Container::]Equals( Value )
Return Value
A byte array of length equal to the number of items in the container. Each element will contain the value 1 if the corresponding container item is equal to Value, or a 0 if the item is not equal.
Arguments
Value
A scalar or array of any simple data type (numbers or strings). The ::Equals method loops through each item in the container, and uses ARRAY_EQUAL to test the item's value against the input Value. For each item in the container, the following rules are used:
Value |
Item value |
Result |
Scalar |
Scalar |
True if the values are equal. |
Scalar |
Array |
True if every element of the array equals Value. |
Array |
Scalar |
True if every element of Value equals the item value. |
Array |
Array |
True if both arrays are the same length and corresponding elements are equal. |
Note: If the types of the two values are different, the type of the least precise is converted to that of the most precise before comparing.
Keywords
None.
Version History
See Also
ARRAY_EQUAL, IDL_Container::Add, IDL_Container::Count, IDL_Container::Get, IDL_Container::IsContained, IDL_Container::Move, IDL_Container::Remove