op_vvec_size_get()

摘要

返回给定值向量中的元素数量。

语法

op_vvec_size_get (vector)
参数 类型 说明
vector Vvec_Vector 目标向量
[该向量是本过程的操作对象,本过程返回该向量中的元素数量。]

返回类型

int

指定向量的总大小(以元素计)。

示例

/* Determine the size of a vector before applying it to an esys interface. */
op_ima_obj_attr_get (interface_id, "dimension", &interface_dim);
if (op_vvec_size_get (src_vector) == interface_dim)
	{
	/* apply the vector value. */
	op_esys_interface_vector_set (interface_id, op_sim_time (), src_vector, 0);
	}
else
	{
	printf ("Error: interface dimension and vector size do not match.\n");
	}

详情

并非所有元素都必须已定义才计入向量大小。值向量的大小等于向量中最后一个元素的索引号加 1。例如下面的向量大小为 6:

vector = {0, 1, 2, 3, 4, 5}

用途

提供一种确定值向量中元素数量的机制。

错误

  • 可恢复错误:值向量无效。

参考

本站文档由 北京智网畅联科技有限公司 整理、翻译并提供 · 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