Java Number Min Value minIndex(int a, int b)

Here you can find the source of minIndex(int a, int b)

Description

Returns the minimum index >= 0, if any

Use to find the first of two characters in a string:
minIndex(s.indexOf('/'), indexOf('\'))

License

Open Source License

Parameter

Parameter Description
a a parameter
b a parameter

Return

the minimum index >= 0, if any

Declaration

public static int minIndex(int a, int b) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2006 Sybase, Inc. and others.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:/*from   www  . j  a  v a2  s  .  c  o m*/
 *     Sybase, Inc. - initial API and implementation
 *******************************************************************************/

public class Main {
    /**
     * Returns the minimum index >= 0, if any
     * 
     * <p>
     * Use to find the first of two characters in a string:<br>
     * <code>minIndex(s.indexOf('/'), indexOf('\'))</code>
     * </p>
     * @param a 
     * @param b 
     * @return the minimum index >= 0, if any
     * 
     */
    public static int minIndex(int a, int b) {
        return (a < 0) ? b : (b < 0) ? a : (a < b) ? a : b;
    }
}

Related

  1. minimum(int a, int b, int c)
  2. minimum(Integer one, Integer two)
  3. minimum(long a, long b, long c)
  4. minimumEditDistance(String target, String source)
  5. minIndent(int a, int b)
  6. minIndex(int ix1, int ix2)
  7. minIndexOfOneOf(String string, int start, String needles)
  8. minInt(double d)
  9. minInt(final Iterable numbers)