Returns a vector produced from the specified one with some elements removed according the specified filtering condition.
The original vector remains unchanged.
Parameters:
v
elemVar
The variable reference must be produced using '@'
operator
(see examples below).
acceptQuery
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
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
.
BooleanQuery(), sortVector(), reverseVector()
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