Here you can find the source of isEqualAsMultiset(List> left, List> right)
Parameter | Description |
---|---|
left | A list. |
right | Another list. |
public static boolean isEqualAsMultiset(List<?> left, List<?> right)
//package com.java2s; //License from project: Open Source License import java.util.List; public class Main { /**// www. ja v a 2 s. c o m * Checks whether two given lists that are interpreted as multi-sets contain the same elements. * The provided lists may be altered during this check. * * @param left A list. * @param right Another list. * @return True if and only if both lists contain equal elements including repetitions. */ public static boolean isEqualAsMultiset(List<?> left, List<?> right) { for (Object e : left) { if (right.contains(e)) { right.remove(e); } else { return false; } } return right.isEmpty(); } }