1.tuple增加操作——tuple_insert
OriginalTuple := [0,1,2,3,4,5]
* 指定索引处插入一个元素
tuple_insert (OriginalTuple, 3, 'x', InsertSingleValueA)
* HDevelop执行同样操作
InsertSingleValueB := insert(OriginalTuple,3,'x')
*
* 指定索引处插入多个元素
tuple_insert (OriginalTuple, 1, ['y','z'], InsertedMultipleValuesA)
* HDevelop执行同样操作
InsertedMultipleValuesB := insert(OriginalTuple,1,['y','z'])
*
* 如果插入索引处刚好为tuple的大小,将会在后面追加
tuple_insert (OriginalTuple, 6, ['x','y','z'], AppendedA)
* HDevelop执行同样操作
AppendedB := insert(OriginalTuple,6,['x','y','z'])
dev_open_tool ('variable_view', 'default', 'default', 'default', 'default', [], [], ToolId)
2.tuple更改操作——tuple_replace
OriginalTuple := [0,1,2,3,4,5]
* 使用不同值替换多个元素
tuple_replace (OriginalTuple, [0,1], ['x','y'], Replaced1)
* HDevelop执行相同操作
Replaced2 := replace(OriginalTuple,[0,1],['x','y'])
*
* 多个元素替换为同一个值
tuple_replace (OriginalTuple, [1,3,5], -111, ReplacedWithOneValue1)
* HDevelop执行相同操作
ReplacedWithOneValue2 := replace(OriginalTuple,[1,3,5],-111)
*
* if index > length of Tuple
* -> Tuple will be extended with appropriate default values
* The default value for numeric tuples is 0
tuple_replace (OriginalTuple, 10, 100, Extended1)
* HDevelop执行相同操作
Extended2 := replace(OriginalTuple,10,100)
* The default value for string tuples is the empty string ''
tuple_replace (['a','b','c','d','e'], [7,10], ['h','k'], StringsExtended1)
* HDevelop执行相同操作
StringsExtended2 := replace(['a','b','c','d','e'],[7,10],['h','k'])
dev_open_tool ('variable_view', 'default', 'default', 'default', 'default', [], [], ToolId)
3.tuple查找——tuple_find
Tuple := [1,2,1,3,1,3,2,5,4,1,8,6]
*
* HDevelop算子速度快于Halcon
*
* 查找单个元素
*
ToFind := 1
*
* 返回所有查找到的索引
IndicesFindA := find(Tuple,ToFind)
tuple_find (Tuple, ToFind, IndicesFindB)
*
* 返回查找到的第一个索引
IndicesFindFirstA := find_first(Tuple,ToFind)
tuple_find_first (Tuple, ToFind, IndicesFindFirstB)
*
* 返回查找到的最后一个索引
IndicesFindLastA := find_last(Tuple,ToFind)
tuple_find_last (Tuple, ToFind, IndicesFindLastB)
*
*
* 查找单个元素的替代方法是将tuple_equal_elem与 tuple_select_mask 一起使用
SelectMaskA := select_mask([0:|Tuple| - 1],Tuple [==] ToFind)
tuple_equal_elem (Tuple, ToFind, EqualB)
tuple_select_mask ([0:|Tuple| - 1], EqualB, SelectMaskB)
*
* 查找子tuple
*
ToFind2 := [1,3]
*
* find
IndicesFindSubA := find(Tuple,ToFind2)
tuple_find (Tuple, ToFind2, IndicesFindSubB)
*
* find_first
IndicesFindFirstSubA := find_first(Tuple,ToFind2)
tuple_find_first (Tuple, ToFind2, IndicesFindFirstSubB)
*
* find_last
IndicesFindLastSubA := find_last(Tuple,ToFind2)
tuple_find_last (Tuple, ToFind2, IndicesFindLastSubB)
*
*
*
* 对于不存在的元素,tuple_find运算符返回 -1*
NotFoundA := find(Tuple,9)
tuple_find (Tuple, 9, NotFoundB)
dev_open_tool ('variable_view', 'default', 'default', 'default', 'default', [], [], ToolId)
4.索引选取子tuple——tuple_select_mask
IntTuple := [0,1,2,3,4,5]
StringTuple := ['abcd','defg','ghij']
*
* 选择得到一个子tuple
tuple_select_mask (IntTuple, [0,1,0,1,0,1], SelectSome1)
* HDevelop执行同样效果
SelectSome2 := select_mask(IntTuple,[0,1,0,1,0,1])
*
* 选择所有元素构建新tuple
tuple_select_mask (IntTuple, [1,1,1,1,1,1], SelectAll1)
* HDevelop执行同样效果
SelectAll2 := select_mask(IntTuple,[1,1,1,1,1,1])
*
* 只选择一个元素构建新的tuple
tuple_select_mask (StringTuple, [0,0,1], SelectOne1)
*HDevelop执行同样效果
SelectOne2 := select_mask(StringTuple,[0,0,1])
dev_open_tool ('variable_view', 'default', 'default', 'default', 'default', [], [], ToolId)
标签:Tuple,default,tuple,OriginalTuple,HDevelop,查改,基本操作,find From: https://www.cnblogs.com/echo-efun/p/18057099