op_vvec_equal()

Abstract

Compares two vectors to see whether they are identical.

Syntax

op_vvec_equal (vector1, vector2)
Argument Type Description
vector1 Vvec_Vector first of two value vectors to compare
vector2 Vvec_Vector second of two value vectors to compare

Return Type

int

OPC_TRUE if the vectors match, OPC_FALSE otherwise.

Example

/* determine if two value vectors are equal. */
if (op_vvec_equal (vector1, vector2))
	{
	/* vector1 and vector2 contain the same elements. */
	printf ("Vectors are equal.\n");
	}
else
	{
	/* Report on inequalities. */

	size1 = op_vvec_size_get (vector1);
	size2 = op_vvec_size_get (vector2);

	if (size1 != size2)
		{
		printf ("Vectors have different sizes.\n);
		printf (“   vector1: %d   vector2: %d\n", size1, size2);
		}

	/* Find out where vector1 and vector2 do not match. */
	size = (size1 < size2) ? size1 : size2; /* size of shorter vector */
	for (i = 0; i < size; i++)
		{
		op_vvec_value_get (vector1, i, &val1);
		op_vvec_value_get (vector2, i, &val2);
		if (val1 != val2)
			printf ("Values at position %d differ.\n", i);
		}
	}

Details

For op_vvec_equal() to return OPC_TRUE, vector1 must contain the same values in the same order as vector2. The two vectors must also have the same number of elements.

Purpose

Provide a mechanism to find out whether two vectors contain the same values.

Errors

  • Recoverable Error: Value vector is invalid.

Reference

  • Use the KP op_vvec_insert() to place elements from one vector into another
  • Use the KP op_vvec_remove() to create a new vector consisting of elements removed from another vector

本站文档由 北京智网畅联科技有限公司 整理、翻译并提供 · Documentation compiled and provided by Beijing ZNetLink Technology Co., Ltd.

交流群 · QQ Group:OPNET/智网妙算网络仿真交流群(群号 486383494)

原文档 © 2017 Riverbed Technology · 本站为公益翻译,由 AI 辅助完成,请仔细甄别

Original documentation © 2017 Riverbed Technology. Community translation, AI-assisted. Contact: jiazequn@znetlink.com