谷神后端集合算法

listStr集合算法。
intersectionListStr
/**
 * intersectionListStr
 * 交集、判空、去重、list实现。
 *
 * $left:list:列表。
 * $right:list:列表。
 *
 * @return intersection:list:交集。
 *
 */
#function intersectionListStr ($left, $right)
	#set($intersection = $vs.util.newList())
	#foreach ($row in $left)
		#if ($vs.util.isNotNull($row) and $right.contains($row) and !$intersection.contains($row))
			$intersection.add($row)
		#end
	#end
	#foreach ($row in $right)
		#if ($vs.util.isNotNull($row) and $left.contains($row) and !$intersection.contains($row))
			$intersection.add($row)
		#end
	#end
	return $intersection
#end
unionListStr
/**
 * unionListStr
 * 并集、判空、去重、list实现。
 *
 * @param $left:list:列表。
 * @param $right:list:列表。
 *
 * @return union:list:并集。
 *
 */
#function unionListStr ($left, $right)
	#set($union = $vs.util.newList())
	#foreach ($row in $left)
		#if ($vs.util.isNotNull($row) and !$union.contains($row))
			$union.add($row)
		#end
	#end
	#foreach ($rowin $right)
		#if ($vs.util.isNotNull($row) and !$union.contains($row))
			$union.add($row)
		#end
	#end
#end
differenceListStr
/**
 * differenceListStr
 * 差集、判空、去重、list实现。
 *
 * $left:list:列表。
 * $right:list:列表。
 *
 * @return difference:list:差集。
 *
 */
#function differenceListStr ($left, $right)
	#set($difference = $vs.util.newList())
	#foreach ($row in $left)
		#if ($vs.util.isNotNull($row) and !$right.contains($row) and !$difference.contains($row))
			$difference.add($row)
		#end
	#end
	return $difference
#end
equalsListStr
/**
 * equalsListStr
 * 比较listStr是否相等。
 *
 * @param $left:list:列表。
 * @param $right:list:列表。
 *
 * @return boolean:布尔。
 *
 */
#function equalsListStr ($left, $right)
	#if ($vs.util.isNull($left) and $vs.util.isNull($right))
		return true
	#end
	#if ($vs.util.isList($left) and $vs.util.isList($right))
		#if ($left.size() ne $right.size())
			return false
		#end
		#foreach ($row in $right)
			#if (!$left.contains($row))
				return false
			#end
		#end
		return true
	#else
		return false
	#end
#end
其它
simpleDifferenceSet
/**
 * simpleDifferenceSet
 * 简单差集
 *
 * $a:list:被减集合
 * $b:list:减集合
 * $fieldId:string:字段域ID
 *
 * @return list:差集
 *
 */
#function simpleDifferenceSet ($a, $b, $fieldId)
	#set($result = $vs.util.newList())
	#set($set = @collectSet($b, $fieldId))
	#foreach ($row in $a)
		#set($value = $row)
		#if ($vs.util.isNotNull($fieldId))
			#set($value = $row.get($fieldId))
		#end
		#if ($vs.util.isNotNull($value) and !$set.contains($fieldId))
			$result.add($row)
		#end
	#end
	return $result
#end
  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值