Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static boolean machesIgnoreOrder (Object[] ... tables){
- if (tables == null){
- throw new NullPointerException();
- }else if (tables.length == 0){
- throw new IllegalArgumentException("tables length cannot equal 0");
- }else if (tables.length == 1){
- return true;
- }
- int size = -1;
- List<Object>[] lists = new ArrayList[tables.length];
- for (int i = 0; i < tables.length; i++){
- Object[] table = tables[i];
- if (table == null){
- throw new NullPointerException();
- }
- if (size != -1 && size != table.length){
- return false;
- }else if (size == -1){
- size = table.length;
- }
- lists[i] = new ArrayList<Object>(Arrays.asList(table));
- }
- for (int i = 0; i < size; i++){
- Object lookingFor = lists[0].get(i);
- for (int ii = 1; ii < lists.length; ii++){
- boolean found = false;
- for (int iii = 0; iii < lists[ii].size(); iii++){
- if (lists[ii].get(iii).equals(lookingFor)){
- lists[ii].remove(iii);
- found = true;
- break;
- }
- }
- if (!found){
- return false;
- }
- }
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment