Mission Base

Program Base Library Functions

int pblListEquals

( PblList* list, void* collection )

Compares the specified collection with this list for equality.

Documentation

Compares the specified collection with this list for equality.

Returns true if and only if the specified collection is a collection, both collections have the same size, and all corresponding pairs of elements in the two collections are equal. (Two elements e1 and e2 are equal if (e1==null ? e2==null : compare( e1, e2 )==0.)

In other words, two collections are defined to be equal as lists if they contain the same elements in the same order.

This implementation first checks if the specified collection is this list. If so, it returns true; if not, it checks if the specified collection is a list or a tree set. If not, it returns false; if so, it iterates over both collections, comparing corresponding pairs of elements by using the compare function of this list. If any comparison returns false, this method returns false. If either iterator runs out of elements before the other it returns false (as the lists are of unequal length); otherwise it returns true when the iterations complete.

This method has a time complexity of O(Min(N,M)), with N being the size of the list and M being the number of elements in the object compared.

Parameters:
list - The list to compare with.
collection - The collection to be compared for equality with this list.
Returns:
int rc > 0: The specified collection is equal to this list.
int rc == 0: The specified collection is not equal to this list.
int rc < 0: An error, see pbl_errno:
PBL_ERROR_PARAM_LIST - The list or collection cannot be iterated.
PBL_ERROR_CONCURRENT_MODIFICATION - The list or collection was modified concurrently.

Alphabetic index



This page was generated with the help of DOC++.