Compare two provider group list, return add list and remove list

@param oldGroups old provider group list
@param newGroups new provider group list
@param add      provider list need add
@param remove   provider list need remove
511352
public static void compareGroups(List<ProviderGroup> oldGroups, List<ProviderGroup> newGroups,
                                     List<ProviderInfo> add,
                                     List<ProviderInfo> remove) {
        // 比较老列表和当前列表
        if (CommonUtils.isEmpty(oldGroups)) {
            // 空变成非空
            if (CommonUtils.isNotEmpty(newGroups)) {
                for (ProviderGroup newGroup : newGroups) {
                    add.addAll(newGroup.getProviderInfos());
                }
            }
            // 空到空，忽略
        } else {
            // 非空变成空
            if (CommonUtils.isEmpty(newGroups)) {
                for (ProviderGroup oldGroup : oldGroups) {
                    remove.addAll(oldGroup.getProviderInfos());
                }
            } else {
                // 非空变成非空，比较
                if (CommonUtils.isNotEmpty(oldGroups)) {
                    Map<String, List<ProviderInfo>> oldMap = convertToMap(oldGroups);
                    Map<String, List<ProviderInfo>> mapTmp = convertToMap(newGroups);
                    // 遍历新的
                    for (Map.Entry<String, List<ProviderInfo>> oldEntry : oldMap.entrySet()) {
                        String key = oldEntry.getKey();
                        List<ProviderInfo> oldList = oldEntry.getValue();
                        if (mapTmp.containsKey(key)) {
                            // 老的有，新的也有，比较变化的部分
                            final List<ProviderInfo> newList = mapTmp.remove(key);
                            compareProviders(oldList, newList, add, remove);
                            mapTmp.remove(key);
                        } else {
                            // 老的有，新的没有
                            remove.addAll(oldList);
                        }
                    }
                    // 新的有，老的没有
                    for (Map.Entry<String, List<ProviderInfo>> entry : mapTmp.entrySet()) {
                        add.addAll(entry.getValue());
                    }
                }
            }
        }
    }
163113
@Override
	public void removeByGroupId(long groupId) {
		for (CommerceDiscountUsageEntry commerceDiscountUsageEntry : findByGroupId(
				groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
			remove(commerceDiscountUsageEntry);
		}
	}
1082852
public boolean deleteGroup(String name)
	{
		if (ADMINISTRATOR_GROUP_ID.equals(name))
		{
			throw new SystemException(String.format("Cannot delete '%s' group.", ADMINISTRATOR_GROUP_ID));
		}

		if (USER_GROUP_ID.equals(name))
		{
			throw new SystemException(String.format("Cannot delete '%s' group.", USER_GROUP_ID));
		}

		if (!isGroupExist(name))
		{
			throw new SystemException(String.format("Group '%s' does not exist.", name));
		}

		if (getGroupUserCount(name) > 0)
		{
			throw new SystemException("Cannot delete a group containing users.");
		}

		return allGroups.remove(name);
	}
1010679
@Override
	public void removeByGroupId(long groupId) {
		for (CPSpecificationOption cpSpecificationOption : findByGroupId(
				groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
			remove(cpSpecificationOption);
		}
	}
559197
def _group_changes(cur, wanted, remove=False):
    '''
    
    '''
    old = set(cur)
    new = set(wanted)
    if (remove and old != new) or (not remove and not new.issubset(old)):
        return True
    return False
1037586
public void insertGroup(int inserted, @Nullable List<L> groups) {
        if (inserted < 0 || inserted >= mCards.size() || groups == null || groups.size() == 0)
            return;

        List<L> cards = getGroups();

        boolean changed = cards.addAll(inserted, groups);

        if (changed)
            setData(cards);
    }
112474
public void setThingGroupsToAdd(java.util.Collection<String> thingGroupsToAdd) {
        if (thingGroupsToAdd == null) {
            this.thingGroupsToAdd = null;
            return;
        }

        this.thingGroupsToAdd = new java.util.ArrayList<String>(thingGroupsToAdd);
    }
343700
@Override
	public void removeByGroupId(long groupId) {
		for (CPOptionValue cpOptionValue : findByGroupId(groupId,
				QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
			remove(cpOptionValue);
		}
	}
543856
@Override
	public void removeByGroupId(long groupId) {
		for (CommerceTaxMethod commerceTaxMethod : findByGroupId(groupId,
				QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
			remove(commerceTaxMethod);
		}
	}
458399
public ProviderGroup add(ProviderInfo providerInfo) {
        if (providerInfo == null) {
            return this;
        }
        ConcurrentHashSet<ProviderInfo> tmp = new ConcurrentHashSet<ProviderInfo>(providerInfos);
        tmp.add(providerInfo); // 排重
        this.providerInfos = new ArrayList<ProviderInfo>(tmp);
        return this;
    }
620391
@Override
	public void removeByGroupId(long groupId) {
		for (CommercePriceList commercePriceList : findByGroupId(groupId,
				QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
			remove(commercePriceList);
		}
	}
1088166
@Override
	public void removeByGroupId(long groupId) {
		for (CommerceCurrency commerceCurrency : findByGroupId(groupId,
				QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
			remove(commerceCurrency);
		}
	}
1142307
@Override
	public CPOption removeByG_K(long groupId, String key)
		throws NoSuchCPOptionException {
		CPOption cpOption = findByG_K(groupId, key);

		return remove(cpOption);
	}
1202867
@Override
	public CPSpecificationOption removeByG_K(long groupId, String key)
		throws NoSuchCPSpecificationOptionException {
		CPSpecificationOption cpSpecificationOption = findByG_K(groupId, key);

		return remove(cpSpecificationOption);
	}
427831
public Response deleteAdminGroup(String roomName, String groupName) {
        return restClient.delete("chatrooms/" + roomName + "/admins/group/" + groupName,
                new HashMap<String, String>());
    }
1202220
public boolean remove() {
		try {
			if(!isBinary)return getJedisCommands(groupName).del(key) == 1;
			if(isCluster(groupName)){
				return getBinaryJedisClusterCommands(groupName).del(keyBytes) == 1;
			}
			return getBinaryJedisCommands(groupName).del(keyBytes) == 1;
		} finally {
			getJedisProvider(groupName).release();
		}
	}
1306101
private void deleteGroup(List<Segment> group) {
    // Delete the old segments.
    for (Segment oldSegment : group) {
      oldSegment.close();
      oldSegment.delete();
    }
  }