Validate the length of the two data sets (must be the same, and non-zero)

@param adapter Data adapter
@param data Data sets
@param <A> First array type
762317
protected static <A> int size(NumberArrayAdapter<?, A> adapter, Collection<? extends A> data) {
    if(data.size() < 2) {
      throw new IllegalArgumentException("Need at least two axes to compute dependence measures.");
    }
    Iterator<? extends A> iter = data.iterator();
    final int len = adapter.size(iter.next());
    while(iter.hasNext()) {
      if(len != adapter.size(iter.next())) {
        throw new IllegalArgumentException("Array sizes do not match!");
      }
    }
    if(len == 0) {
      throw new IllegalArgumentException("Empty array!");
    }
    return len;
  }
448641
@SuppressWarnings("unchecked")
    public void setAdapter(@Nullable AdaptiveTableAdapter adapter) {
        if (mAdapter != null) {
            // remove observers from old adapter
            mAdapter.unregisterDataSetObserver(this);
        }

        if (adapter != null) {
            // wrap adapter
            mAdapter = new LinkedAdaptiveTableAdapterImpl<>(adapter, mSettings.isSolidRowHeader());
            // register notify callbacks
            mAdapter.registerDataSetObserver(this);
            adapter.registerDataSetObserver(new DataSetObserverProxy(mAdapter));
        } else {
            // remove adapter
            mAdapter = null;
        }
        initItems();
    }
4001
protected static void checkSameExecutionContext(DataSet<?> set1, DataSet<?> set2) {
		if (set1.context != set2.context) {
			throw new IllegalArgumentException("The two inputs have different execution contexts.");
		}
	}
1038313
public final void setDatas(@NonNull Iterable<? extends Data<?>> datas) {
        checkNotNull(datas, "datas");
        mDataWatcher.setDatas(datas);
        mDatas.clear();
        for (Data<?> data : datas) {
            mDatas.add(data);
        }
        // Clear error message, because the caller expects the view state to be reset when all datas change
        if (mDatas.isEmpty()) {
            mErrorMessage = null;
        }
        updateViews();
    }
511723
public static int[] validate1(int[] data, String paramName){
        if(data == null) {
            return null;
        }

        Preconditions.checkArgument(data.length == 1,
                "Need 1 %s value, got %s values: %s",
                        paramName, data.length, data);

        return data;
    }
858397
@Override
	protected void validateComponent(final List<Diagnostic> diags) {
		String text1 = field1.getText();
		String text2 = field2.getText();
		String text3 = field3.getText();

		if (text1 != null && text1.length() > 0 && text1.equals(text2)) {
			// Note that this error will hyperlink to Field 2.
			diags.add(createErrorDiagnostic(field2, "Fields 1 and 2 cannot be the same."));
		}

		int len = 0;
		if (text1 != null) {
			len += text1.length();
		}
		if (text2 != null) {
			len += text2.length();
		}
		if (len > 20) {
			// Note that this error does not link to a specific field.
			diags.add(createErrorDiagnostic(
					"The total length of Field 1 plus Field 2 can exceed 20 characters."));
		}

		// Sample Warning Message
		if (Util.empty(text3)) {
			diags.add(new DiagnosticImpl(Diagnostic.WARNING, UIContextHolder.getCurrent(), field3,
					"Warning that this should not be blank"));
		}
	}
937450
private static function checkArrayLengths(array $arrays): bool
    {
        if (count($arrays) < 2) {
            throw new Exception\BadDataException('Need at least two arrays to map over');
        }

        $n = count($arrays[0]);
        foreach ($arrays as $array) {
            if (count($array) !== $n) {
                throw new Exception\BadDataException('Lengths of arrays are not equal');
            }
        }

        return true;
    }
649129
public static <A extends ModelAdapter<Model, Item>, Model, Item extends IItem> DiffUtil.DiffResult calculateDiff(final A adapter, final List<Item> items, final DiffCallback<Item> callback) {
        return calculateDiff(adapter, items, callback, true);
    }
1248755
public void setAdapter(PagerAdapter adapter) {
        if (mAdapter != null) {
            mAdapter.unregisterDataSetObserver(mObserver);
            mAdapter.startUpdate(this);
            for (int i = 0; i < mItems.size(); i++) {
                final ItemInfo ii = mItems.get(i);
                mAdapter.destroyItem(this, ii.position, ii.object);
            }
            mAdapter.finishUpdate(this);
            mItems.clear();
            removeNonDecorViews();
            mCurItem = 0;
            scrollTo(0, 0);
        }

        final PagerAdapter oldAdapter = mAdapter;
        mAdapter = adapter;
        mExpectedAdapterCount = 0;

        if (mAdapter != null) {
            if (mObserver == null) {
                mObserver = new PagerObserver();
            }
            mAdapter.registerDataSetObserver(mObserver);
            mPopulatePending = false;
            final boolean wasFirstLayout = mFirstLayout;
            mFirstLayout = true;
            mExpectedAdapterCount = mAdapter.getCount();
            if (mRestoredCurItem >= 0) {
                mAdapter.restoreState(mRestoredAdapterState, mRestoredClassLoader);
                setCurrentItemInternal(mRestoredCurItem, false, true);
                mRestoredCurItem = -1;
                mRestoredAdapterState = null;
                mRestoredClassLoader = null;
            } else if (!wasFirstLayout) {
                populate();
            } else {
                requestLayout();
            }
        }

        if (mAdapterChangeListener != null && oldAdapter != adapter) {
            mAdapterChangeListener.onAdapterChanged(oldAdapter, adapter);
        }
    }
182994
private int setSecDataArr(ArrayList inArr, ArrayList outArr) {

        if (!inArr.isEmpty()) {
            for (int j = 0; j < outArr.size(); j++) {
                if (outArr.get(j).equals(inArr)) {
                    return j + 1;
                }
            }
            outArr.add(inArr);
            return outArr.size();
        } else {
            return 0;
        }
    }
314335
protected static <A> double[] computeDistances(NumberArrayAdapter<?, A> adapter, A data) {
    final int size = adapter.size(data);
    double[] dMatrix = new double[(size * (size + 1)) >> 1];
    for(int i = 0, c = 0; i < size; i++) {
      for(int j = 0; j < i; j++) {
        double dx = adapter.getDouble(data, i) - adapter.getDouble(data, j);
        dMatrix[c++] = (dx < 0) ? -dx : dx; // Absolute difference.
      }
      c++; // Diagonal entry: zero
    }
    doubleCenterMatrix(dMatrix, size);
    return dMatrix;
  }
1093941
public void readArray(long[] data) throws IOException {
        int size = data.length;
        for (int i = 0; i < size; ++i)
            data[i] = getLong();
    }
509356
public void setAdapter(ListAdapter adapter) {
        if (mAdapter != null) {
            mAdapter.unregisterDataSetObserver(mDataObserver);
        }

        mAdapter = adapter;

        if (mAdapter != null) {
            mAdapter.registerDataSetObserver(mDataObserver);
            mAreAllItemsSelectable = mAdapter.areAllItemsEnabled();
        }

        setupChildren();

    }
587944
public void loadKeys(DataStructureAdapter<Object, ?> adapter) {
        if (!storeFile.exists()) {
            logger.info(format("Skipped loading keys of Near Cache %s since storage file doesn't exist (%s)", nearCacheName,
                    storeFile.getAbsolutePath()));
            return;
        }

        long startedNanos = System.nanoTime();
        BufferingInputStream bis = null;
        try {
            bis = new BufferingInputStream(new FileInputStream(storeFile), BUFFER_SIZE);
            if (!checkHeader(bis)) {
                return;
            }

            int loadedKeys = loadKeySet(bis, adapter);

            long elapsedMillis = getElapsedMillis(startedNanos);
            logger.info(format("Loaded %d keys of Near Cache %s in %d ms", loadedKeys, nearCacheName, elapsedMillis));
        } catch (Exception e) {
            logger.warning(format("Could not pre-load Near Cache %s (%s)", nearCacheName, storeFile.getAbsolutePath()), e);
        } finally {
            closeResource(bis);
        }
    }
57730
@Override
	protected void validateComponent(final List<Diagnostic> diags) {
		super.validateComponent(diags);

		if (!isEmpty()) {
			String value = getValueAsString();

			// Minimum Length
			int min = getMinLength();

			if (min > 0 && value.length() < min) {
				diags.add(
						createErrorDiagnostic(InternalMessages.DEFAULT_VALIDATION_ERROR_MIN_LENGTH,
								this,
								String.valueOf(min)));
			}

			// Maximum Length
			int max = getMaxLength();

			if (max > 0 && value.length() > max) {
				diags.add(
						createErrorDiagnostic(InternalMessages.DEFAULT_VALIDATION_ERROR_MAX_LENGTH,
								this,
								String.valueOf(max)));
			}
		}
	}
616144
public static void validateNotEmptyAndEqual(Object t1, Object t2, String errorMsg) throws ValidateException {
		validateNotEmpty(t1, errorMsg);
		validateEqual(t1, t2, errorMsg);
	}
1004946
public void setListAdapter(ListAdapter adapter) {
        boolean hadAdapter = mAdapter != null;
        mAdapter = adapter;
        if (mList != null) {
            mList.setAdapter(adapter);
            if (!mListShown && !hadAdapter) {
                // The list was hidden, and previously didn't have an
                // adapter.  It is now time to show it.
                setListShown(true, getView().getWindowToken() != null);
            }
        }
    }