Returns a vector produced from the specified one with some elements removed according the specified filtering condition.

The original vector remains unchanged.

Parameters:

v

The initial vector to be filtered.
elemVar
The reference to the variable to which the element is assigned to pass it to the filtering subquery.

The variable reference must be produced using '@' operator (see examples below).

acceptQuery
Specifies the filtering subquery.

When specified, it is executed for each initial vector element. The subquery should return true if the element must be included in the result vector or false otherwise.

The subquery should be prepared using BooleanQuery() function (see examples below).

You may specify null in this parameter, if you need only to remove from the initial vector all repeating elements (see unique parameter below).

unique
Specifies whether the result vector must contain only unique elements.

If true all repeating elements will be removed; if false all original elements will be present in the result vector.

The elements are compared according to the Java Object.equals() method. When there are more than 10 initial elements, a hash map is used, in which case the elements serve as hash keys.

When this parameter is omitted, it is assumed to be false.

Returns:

The new vector containing filtered elements. The original element order is preserved.

See Also:

BooleanQuery(), sortVector(), reverseVector()

Example:

The following expression removes from the initial vector all null elements an all repeating elements and prints the result vector to the system console:


// the original vector
v = Vector ("blah", "blah", null, "1");

// create a new filtered vector
v = v.filterVector (
  @elem, 
  BooleanQuery (elem != null),
  true
);

echo (v) // print the result vector