zoukankan      html  css  js  c++  java
  • java.util.Arrays.binarySearch方法

    java.util.Arrays.binarySearch方法

    Modifier and Type 方法 描述
    static int binarySearch(byte[] a, byte key) 使用二进制搜索算法搜索指定值的指定字节数组。
    static int binarySearch(byte[] a, int fromIndex, int toIndex, byte key) 使用二进制搜索算法搜索指定值的指定字节数组的范围。
    static int binarySearch(char[] a, char key) 使用二进制搜索算法搜索指定数组的指定值。
    static int binarySearch(char[] a, int fromIndex, int toIndex, char key) 使用二分搜索算法搜索指定值的指定数组的范围。
    static int binarySearch(double[] a, double key) 使用二进制搜索算法搜索指定值的指定数组的双精度值。
    static int binarySearch(double[] a, int fromIndex, int toIndex, double key) 使用二分搜索算法搜索指定值的指定数组的双精度范围。
    static int binarySearch(float[] a, float key) 使用二叉搜索算法搜索指定数组的浮点数。
    static int binarySearch(float[] a, int fromIndex, int toIndex, float key) 使用二分搜索算法搜索指定数组的浮点数范围。
    static int binarySearch(int[] a, int key) 使用二叉搜索算法搜索指定的int数组的指定值。
    static int binarySearch(int[] a, int fromIndex, int toIndex, int key) 使用二叉搜索算法搜索指定值的指定数组的范围。
    static int binarySearch(long[] a, int fromIndex, int toIndex, long key) 使用二分搜索算法搜索指定值的指定数组的范围。
    static int binarySearch(long[] a, long key) 使用二进制搜索算法搜索指定数组的指定数组。
    static int binarySearch(short[] a, int fromIndex, int toIndex, short key) 使用二进制搜索算法搜索指定值的指定数组的短整型范围。
    static int binarySearch(short[] a, short key) 使用二进制搜索算法搜索指定值的指定数组的指定值。
    static int binarySearch(Object[] a, int fromIndex, int toIndex, Object key) 使用二进制搜索算法搜索指定对象的指定数组的范围。
    static int binarySearch(Object[] a, Object key) 使用二叉搜索算法搜索指定对象的指定数组。
    static int binarySearch(T[] a, int fromIndex, int toIndex, T key, Comparator c) 使用二进制搜索算法搜索指定对象的指定数组的范围。
    static int binarySearch(T[] a, T key, Comparator c) 使用二叉搜索算法搜索指定对象的指定数组。

    binarySearch(int[] a, int key)

    import java.util.Arrays;
    
    public class TestBinarySearch {
        public static void main(String[] args) {
            test();
    
        }
        //测试  binarySearch()方法
        public static void test(){
            int[] a = {1,2,3,5,10,8};
            Arrays.sort(a);
            System.out.println("排序后的数组为:"+Arrays.toString(a));
            int index = Arrays.binarySearch(a, 5);
            System.out.println("5在排序后数组的位置为:"+index);
    
        }
    }
    
    
    排序后的数组为:[1, 2, 3, 5, 8, 10]
    5在排序后数组的位置为:3
    
  • 相关阅读:
    通过actionlib控制jaco机械臂
    actionlib学习
    配置 jaco机械臂 ros环境
    ubuntu14.04标题栏显示上下网速
    linux下alsa架构音频驱动播放wav格式文件
    ros语音交互(五)移植科大讯飞语音识别到ros
    ubuntu14.04 wifi驱动
    Ubuntu14.04使用apt-fast来加快apt-get下载的教程
    ROS语音交互(四)接入图灵语义理解
    相比传统游戏,区块链游戏的价值在哪里?
  • 原文地址:https://www.cnblogs.com/sweetorangezzz/p/12918617.html
Copyright © 2011-2022 走看看