简单随机数据算法

文章目录

一,需求概述

系统启动时,读取一组图片数据,通过接口返回给前台,要求:

  • 图片随机
  • 相邻图片不重复

二,实现代码

借助Queue实现FIFO

java 复制代码
/**
 * 随机索引<br>
 */
@Slf4j
public class RandomIndex
{
    int length;
    
    byte[] lock = new byte[0];
    
    Queue<Integer> quque = new ConcurrentLinkedQueue<>();
    
    /**
     * 实例化
     * 
     * @param length 总数据长度
     */
    public RandomIndex(int length)
    {
        super();
        this.length = length;
    }
    
    /**
     * 返回与最近数据不重复的随机索引值
     * 
     * @return
     */
    public int getIndex()
    {
        // 集中1次生成不超过20条数据,多次使用
        int ququeMaxSize = Math.min(length, 20);
        if (quque.size() < 3 || quque.size() < ququeMaxSize / 2)
        {
            synchronized (lock)
            {
                int add;
                while (quque.size() < ququeMaxSize)
                {
                    add = RandomUtils.nextInt(0, length);
                    if (!quque.contains(add))
                    {
                        quque.add(add);
                    }
                }
            }
            log.info("{}", quque);
        }
        int index = quque.poll();
        log.info("{} <= {}", index, quque);
        return index;
    }
}

三、测试代码

java 复制代码
@Slf4j
public class RandomIndexTest
{
    @Test
    public void test()
    {
        try (Scanner sc = new Scanner(System.in))
        {
            do
            {
                // 索引最大值[2,40),连续获取次数[20,100)
                int size = RandomUtils.nextInt(2, 40);
                int count = RandomUtils.nextInt(20, 100);
                log.info("###### size: {}, count: {}", size, count);
                RandomIndex randomIndex = new RandomIndex(size);
                IntStream.range(0, count).forEach(i -> randomIndex.getIndex());
                
                log.info("------------输入x退出,回车换行继续------------");
            } while (!"x".equalsIgnoreCase(sc.nextLine()));
            log.info("------------成功退出------------");
        }
    }
}

四、测试结果

bash 复制代码
2024-05-28 22:41:03.107  INFO 4788 --- [main] c.f.h.s.RandomIndexTest        : ###### size: 37, count: 43
2024-05-28 22:41:03.107  INFO 4788 --- [main] c.f.h.c.RandomIndex            : [2, 6, 35, 11, 14, 28, 17, 12, 13, 21, 33, 36, 24, 30, 31, 25, 18, 0, 26, 32]
2024-05-28 22:41:03.107  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 2 <= [6, 35, 11, 14, 28, 17, 12, 13, 21, 33, 36, 24, 30, 31, 25, 18, 0, 26, 32]
2024-05-28 22:41:03.107  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 6 <= [35, 11, 14, 28, 17, 12, 13, 21, 33, 36, 24, 30, 31, 25, 18, 0, 26, 32]
2024-05-28 22:41:03.107  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 35 <= [11, 14, 28, 17, 12, 13, 21, 33, 36, 24, 30, 31, 25, 18, 0, 26, 32]
2024-05-28 22:41:03.107  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 11 <= [14, 28, 17, 12, 13, 21, 33, 36, 24, 30, 31, 25, 18, 0, 26, 32]
2024-05-28 22:41:03.107  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 14 <= [28, 17, 12, 13, 21, 33, 36, 24, 30, 31, 25, 18, 0, 26, 32]
2024-05-28 22:41:03.107  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 28 <= [17, 12, 13, 21, 33, 36, 24, 30, 31, 25, 18, 0, 26, 32]
2024-05-28 22:41:03.107  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 17 <= [12, 13, 21, 33, 36, 24, 30, 31, 25, 18, 0, 26, 32]
2024-05-28 22:41:03.107  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 12 <= [13, 21, 33, 36, 24, 30, 31, 25, 18, 0, 26, 32]
2024-05-28 22:41:03.107  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 13 <= [21, 33, 36, 24, 30, 31, 25, 18, 0, 26, 32]
2024-05-28 22:41:03.107  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 21 <= [33, 36, 24, 30, 31, 25, 18, 0, 26, 32]
2024-05-28 22:41:03.107  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 33 <= [36, 24, 30, 31, 25, 18, 0, 26, 32]
2024-05-28 22:41:03.107  INFO 4788 --- [main] c.f.h.c.RandomIndex            : [36, 24, 30, 31, 25, 18, 0, 26, 32, 17, 14, 2, 1, 34, 10, 4, 22, 6, 3, 8]
2024-05-28 22:41:03.107  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 36 <= [24, 30, 31, 25, 18, 0, 26, 32, 17, 14, 2, 1, 34, 10, 4, 22, 6, 3, 8]
2024-05-28 22:41:03.107  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 24 <= [30, 31, 25, 18, 0, 26, 32, 17, 14, 2, 1, 34, 10, 4, 22, 6, 3, 8]
2024-05-28 22:41:03.107  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 30 <= [31, 25, 18, 0, 26, 32, 17, 14, 2, 1, 34, 10, 4, 22, 6, 3, 8]
2024-05-28 22:41:03.107  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 31 <= [25, 18, 0, 26, 32, 17, 14, 2, 1, 34, 10, 4, 22, 6, 3, 8]
2024-05-28 22:41:03.107  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 25 <= [18, 0, 26, 32, 17, 14, 2, 1, 34, 10, 4, 22, 6, 3, 8]
2024-05-28 22:41:03.107  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 18 <= [0, 26, 32, 17, 14, 2, 1, 34, 10, 4, 22, 6, 3, 8]
2024-05-28 22:41:03.107  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 0 <= [26, 32, 17, 14, 2, 1, 34, 10, 4, 22, 6, 3, 8]
2024-05-28 22:41:03.107  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 26 <= [32, 17, 14, 2, 1, 34, 10, 4, 22, 6, 3, 8]
2024-05-28 22:41:03.108  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 32 <= [17, 14, 2, 1, 34, 10, 4, 22, 6, 3, 8]
2024-05-28 22:41:03.108  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 17 <= [14, 2, 1, 34, 10, 4, 22, 6, 3, 8]
2024-05-28 22:41:03.108  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 14 <= [2, 1, 34, 10, 4, 22, 6, 3, 8]
2024-05-28 22:41:03.108  INFO 4788 --- [main] c.f.h.c.RandomIndex            : [2, 1, 34, 10, 4, 22, 6, 3, 8, 20, 18, 16, 29, 35, 30, 27, 25, 23, 21, 33]
2024-05-28 22:41:03.108  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 2 <= [1, 34, 10, 4, 22, 6, 3, 8, 20, 18, 16, 29, 35, 30, 27, 25, 23, 21, 33]
2024-05-28 22:41:03.108  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 1 <= [34, 10, 4, 22, 6, 3, 8, 20, 18, 16, 29, 35, 30, 27, 25, 23, 21, 33]
2024-05-28 22:41:03.108  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 34 <= [10, 4, 22, 6, 3, 8, 20, 18, 16, 29, 35, 30, 27, 25, 23, 21, 33]
2024-05-28 22:41:03.108  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 10 <= [4, 22, 6, 3, 8, 20, 18, 16, 29, 35, 30, 27, 25, 23, 21, 33]
2024-05-28 22:41:03.108  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 4 <= [22, 6, 3, 8, 20, 18, 16, 29, 35, 30, 27, 25, 23, 21, 33]
2024-05-28 22:41:03.108  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 22 <= [6, 3, 8, 20, 18, 16, 29, 35, 30, 27, 25, 23, 21, 33]
2024-05-28 22:41:03.108  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 6 <= [3, 8, 20, 18, 16, 29, 35, 30, 27, 25, 23, 21, 33]
2024-05-28 22:41:03.108  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 3 <= [8, 20, 18, 16, 29, 35, 30, 27, 25, 23, 21, 33]
2024-05-28 22:41:03.108  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 8 <= [20, 18, 16, 29, 35, 30, 27, 25, 23, 21, 33]
2024-05-28 22:41:03.108  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 20 <= [18, 16, 29, 35, 30, 27, 25, 23, 21, 33]
2024-05-28 22:41:03.108  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 18 <= [16, 29, 35, 30, 27, 25, 23, 21, 33]
2024-05-28 22:41:03.108  INFO 4788 --- [main] c.f.h.c.RandomIndex            : [16, 29, 35, 30, 27, 25, 23, 21, 33, 15, 1, 17, 9, 22, 12, 14, 20, 18, 24, 0]
2024-05-28 22:41:03.108  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 16 <= [29, 35, 30, 27, 25, 23, 21, 33, 15, 1, 17, 9, 22, 12, 14, 20, 18, 24, 0]
2024-05-28 22:41:03.108  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 29 <= [35, 30, 27, 25, 23, 21, 33, 15, 1, 17, 9, 22, 12, 14, 20, 18, 24, 0]
2024-05-28 22:41:03.108  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 35 <= [30, 27, 25, 23, 21, 33, 15, 1, 17, 9, 22, 12, 14, 20, 18, 24, 0]
2024-05-28 22:41:03.109  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 30 <= [27, 25, 23, 21, 33, 15, 1, 17, 9, 22, 12, 14, 20, 18, 24, 0]
2024-05-28 22:41:03.109  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 27 <= [25, 23, 21, 33, 15, 1, 17, 9, 22, 12, 14, 20, 18, 24, 0]
2024-05-28 22:41:03.109  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 25 <= [23, 21, 33, 15, 1, 17, 9, 22, 12, 14, 20, 18, 24, 0]
2024-05-28 22:41:03.109  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 23 <= [21, 33, 15, 1, 17, 9, 22, 12, 14, 20, 18, 24, 0]
2024-05-28 22:41:03.109  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 21 <= [33, 15, 1, 17, 9, 22, 12, 14, 20, 18, 24, 0]
2024-05-28 22:41:03.109  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 33 <= [15, 1, 17, 9, 22, 12, 14, 20, 18, 24, 0]
2024-05-28 22:41:03.109  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 15 <= [1, 17, 9, 22, 12, 14, 20, 18, 24, 0]
2024-05-28 22:41:03.109  INFO 4788 --- [main] c.f.h.s.RandomIndexTest        : ------------输入x退出,回车换行继续------------

2024-05-28 22:41:04.146  INFO 4788 --- [main] c.f.h.s.RandomIndexTest        : ###### size: 20, count: 65
2024-05-28 22:41:04.146  INFO 4788 --- [main] c.f.h.c.RandomIndex            : [12, 2, 17, 14, 16, 3, 18, 19, 9, 13, 10, 11, 6, 1, 5, 4, 8, 15, 7, 0]
2024-05-28 22:41:04.146  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 12 <= [2, 17, 14, 16, 3, 18, 19, 9, 13, 10, 11, 6, 1, 5, 4, 8, 15, 7, 0]
2024-05-28 22:41:04.146  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 2 <= [17, 14, 16, 3, 18, 19, 9, 13, 10, 11, 6, 1, 5, 4, 8, 15, 7, 0]
2024-05-28 22:41:04.146  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 17 <= [14, 16, 3, 18, 19, 9, 13, 10, 11, 6, 1, 5, 4, 8, 15, 7, 0]
2024-05-28 22:41:04.146  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 14 <= [16, 3, 18, 19, 9, 13, 10, 11, 6, 1, 5, 4, 8, 15, 7, 0]
2024-05-28 22:41:04.146  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 16 <= [3, 18, 19, 9, 13, 10, 11, 6, 1, 5, 4, 8, 15, 7, 0]
2024-05-28 22:41:04.147  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 3 <= [18, 19, 9, 13, 10, 11, 6, 1, 5, 4, 8, 15, 7, 0]
2024-05-28 22:41:04.147  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 18 <= [19, 9, 13, 10, 11, 6, 1, 5, 4, 8, 15, 7, 0]
2024-05-28 22:41:04.147  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 19 <= [9, 13, 10, 11, 6, 1, 5, 4, 8, 15, 7, 0]
2024-05-28 22:41:04.147  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 9 <= [13, 10, 11, 6, 1, 5, 4, 8, 15, 7, 0]
2024-05-28 22:41:04.147  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 13 <= [10, 11, 6, 1, 5, 4, 8, 15, 7, 0]
2024-05-28 22:41:04.147  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 10 <= [11, 6, 1, 5, 4, 8, 15, 7, 0]
2024-05-28 22:41:04.147  INFO 4788 --- [main] c.f.h.c.RandomIndex            : [11, 6, 1, 5, 4, 8, 15, 7, 0, 13, 2, 18, 17, 14, 19, 9, 16, 3, 10, 12]
2024-05-28 22:41:04.147  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 11 <= [6, 1, 5, 4, 8, 15, 7, 0, 13, 2, 18, 17, 14, 19, 9, 16, 3, 10, 12]
2024-05-28 22:41:04.147  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 6 <= [1, 5, 4, 8, 15, 7, 0, 13, 2, 18, 17, 14, 19, 9, 16, 3, 10, 12]
2024-05-28 22:41:04.147  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 1 <= [5, 4, 8, 15, 7, 0, 13, 2, 18, 17, 14, 19, 9, 16, 3, 10, 12]
2024-05-28 22:41:04.147  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 5 <= [4, 8, 15, 7, 0, 13, 2, 18, 17, 14, 19, 9, 16, 3, 10, 12]
2024-05-28 22:41:04.147  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 4 <= [8, 15, 7, 0, 13, 2, 18, 17, 14, 19, 9, 16, 3, 10, 12]
2024-05-28 22:41:04.147  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 8 <= [15, 7, 0, 13, 2, 18, 17, 14, 19, 9, 16, 3, 10, 12]
2024-05-28 22:41:04.147  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 15 <= [7, 0, 13, 2, 18, 17, 14, 19, 9, 16, 3, 10, 12]
2024-05-28 22:41:04.147  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 7 <= [0, 13, 2, 18, 17, 14, 19, 9, 16, 3, 10, 12]
2024-05-28 22:41:04.147  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 0 <= [13, 2, 18, 17, 14, 19, 9, 16, 3, 10, 12]
2024-05-28 22:41:04.147  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 13 <= [2, 18, 17, 14, 19, 9, 16, 3, 10, 12]
2024-05-28 22:41:04.148  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 2 <= [18, 17, 14, 19, 9, 16, 3, 10, 12]
2024-05-28 22:41:04.148  INFO 4788 --- [main] c.f.h.c.RandomIndex            : [18, 17, 14, 19, 9, 16, 3, 10, 12, 4, 8, 11, 13, 0, 6, 7, 2, 5, 15, 1]
2024-05-28 22:41:04.148  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 18 <= [17, 14, 19, 9, 16, 3, 10, 12, 4, 8, 11, 13, 0, 6, 7, 2, 5, 15, 1]
2024-05-28 22:41:04.148  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 17 <= [14, 19, 9, 16, 3, 10, 12, 4, 8, 11, 13, 0, 6, 7, 2, 5, 15, 1]
2024-05-28 22:41:04.148  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 14 <= [19, 9, 16, 3, 10, 12, 4, 8, 11, 13, 0, 6, 7, 2, 5, 15, 1]
2024-05-28 22:41:04.148  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 19 <= [9, 16, 3, 10, 12, 4, 8, 11, 13, 0, 6, 7, 2, 5, 15, 1]
2024-05-28 22:41:04.148  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 9 <= [16, 3, 10, 12, 4, 8, 11, 13, 0, 6, 7, 2, 5, 15, 1]
2024-05-28 22:41:04.148  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 16 <= [3, 10, 12, 4, 8, 11, 13, 0, 6, 7, 2, 5, 15, 1]
2024-05-28 22:41:04.148  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 3 <= [10, 12, 4, 8, 11, 13, 0, 6, 7, 2, 5, 15, 1]
2024-05-28 22:41:04.148  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 10 <= [12, 4, 8, 11, 13, 0, 6, 7, 2, 5, 15, 1]
2024-05-28 22:41:04.148  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 12 <= [4, 8, 11, 13, 0, 6, 7, 2, 5, 15, 1]
2024-05-28 22:41:04.148  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 4 <= [8, 11, 13, 0, 6, 7, 2, 5, 15, 1]
2024-05-28 22:41:04.148  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 8 <= [11, 13, 0, 6, 7, 2, 5, 15, 1]
2024-05-28 22:41:04.148  INFO 4788 --- [main] c.f.h.c.RandomIndex            : [11, 13, 0, 6, 7, 2, 5, 15, 1, 10, 4, 14, 17, 18, 12, 8, 16, 3, 9, 19]
2024-05-28 22:41:04.149  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 11 <= [13, 0, 6, 7, 2, 5, 15, 1, 10, 4, 14, 17, 18, 12, 8, 16, 3, 9, 19]
2024-05-28 22:41:04.149  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 13 <= [0, 6, 7, 2, 5, 15, 1, 10, 4, 14, 17, 18, 12, 8, 16, 3, 9, 19]
2024-05-28 22:41:04.149  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 0 <= [6, 7, 2, 5, 15, 1, 10, 4, 14, 17, 18, 12, 8, 16, 3, 9, 19]
2024-05-28 22:41:04.149  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 6 <= [7, 2, 5, 15, 1, 10, 4, 14, 17, 18, 12, 8, 16, 3, 9, 19]
2024-05-28 22:41:04.149  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 7 <= [2, 5, 15, 1, 10, 4, 14, 17, 18, 12, 8, 16, 3, 9, 19]
2024-05-28 22:41:04.149  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 2 <= [5, 15, 1, 10, 4, 14, 17, 18, 12, 8, 16, 3, 9, 19]
2024-05-28 22:41:04.149  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 5 <= [15, 1, 10, 4, 14, 17, 18, 12, 8, 16, 3, 9, 19]
2024-05-28 22:41:04.149  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 15 <= [1, 10, 4, 14, 17, 18, 12, 8, 16, 3, 9, 19]
2024-05-28 22:41:04.149  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 1 <= [10, 4, 14, 17, 18, 12, 8, 16, 3, 9, 19]
2024-05-28 22:41:04.149  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 10 <= [4, 14, 17, 18, 12, 8, 16, 3, 9, 19]
2024-05-28 22:41:04.149  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 4 <= [14, 17, 18, 12, 8, 16, 3, 9, 19]
2024-05-28 22:41:04.149  INFO 4788 --- [main] c.f.h.c.RandomIndex            : [14, 17, 18, 12, 8, 16, 3, 9, 19, 2, 0, 7, 4, 10, 13, 6, 1, 5, 11, 15]
2024-05-28 22:41:04.149  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 14 <= [17, 18, 12, 8, 16, 3, 9, 19, 2, 0, 7, 4, 10, 13, 6, 1, 5, 11, 15]
2024-05-28 22:41:04.150  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 17 <= [18, 12, 8, 16, 3, 9, 19, 2, 0, 7, 4, 10, 13, 6, 1, 5, 11, 15]
2024-05-28 22:41:04.150  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 18 <= [12, 8, 16, 3, 9, 19, 2, 0, 7, 4, 10, 13, 6, 1, 5, 11, 15]
2024-05-28 22:41:04.150  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 12 <= [8, 16, 3, 9, 19, 2, 0, 7, 4, 10, 13, 6, 1, 5, 11, 15]
2024-05-28 22:41:04.150  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 8 <= [16, 3, 9, 19, 2, 0, 7, 4, 10, 13, 6, 1, 5, 11, 15]
2024-05-28 22:41:04.150  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 16 <= [3, 9, 19, 2, 0, 7, 4, 10, 13, 6, 1, 5, 11, 15]
2024-05-28 22:41:04.150  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 3 <= [9, 19, 2, 0, 7, 4, 10, 13, 6, 1, 5, 11, 15]
2024-05-28 22:41:04.150  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 9 <= [19, 2, 0, 7, 4, 10, 13, 6, 1, 5, 11, 15]
2024-05-28 22:41:04.150  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 19 <= [2, 0, 7, 4, 10, 13, 6, 1, 5, 11, 15]
2024-05-28 22:41:04.150  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 2 <= [0, 7, 4, 10, 13, 6, 1, 5, 11, 15]
2024-05-28 22:41:04.150  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 0 <= [7, 4, 10, 13, 6, 1, 5, 11, 15]
2024-05-28 22:41:04.150  INFO 4788 --- [main] c.f.h.c.RandomIndex            : [7, 4, 10, 13, 6, 1, 5, 11, 15, 12, 0, 18, 16, 2, 3, 19, 8, 14, 17, 9]
2024-05-28 22:41:04.150  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 7 <= [4, 10, 13, 6, 1, 5, 11, 15, 12, 0, 18, 16, 2, 3, 19, 8, 14, 17, 9]
2024-05-28 22:41:04.150  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 4 <= [10, 13, 6, 1, 5, 11, 15, 12, 0, 18, 16, 2, 3, 19, 8, 14, 17, 9]
2024-05-28 22:41:04.150  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 10 <= [13, 6, 1, 5, 11, 15, 12, 0, 18, 16, 2, 3, 19, 8, 14, 17, 9]
2024-05-28 22:41:04.150  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 13 <= [6, 1, 5, 11, 15, 12, 0, 18, 16, 2, 3, 19, 8, 14, 17, 9]
2024-05-28 22:41:04.150  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 6 <= [1, 5, 11, 15, 12, 0, 18, 16, 2, 3, 19, 8, 14, 17, 9]
2024-05-28 22:41:04.150  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 1 <= [5, 11, 15, 12, 0, 18, 16, 2, 3, 19, 8, 14, 17, 9]
2024-05-28 22:41:04.150  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 5 <= [11, 15, 12, 0, 18, 16, 2, 3, 19, 8, 14, 17, 9]
2024-05-28 22:41:04.150  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 11 <= [15, 12, 0, 18, 16, 2, 3, 19, 8, 14, 17, 9]
2024-05-28 22:41:04.150  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 15 <= [12, 0, 18, 16, 2, 3, 19, 8, 14, 17, 9]
2024-05-28 22:41:04.150  INFO 4788 --- [main] c.f.h.c.RandomIndex            : 12 <= [0, 18, 16, 2, 3, 19, 8, 14, 17, 9]
2024-05-28 22:41:04.150  INFO 4788 --- [main] c.f.h.s.RandomIndexTest        : ------------输入x退出,回车换行继续------------

五、源码传送

https://gitcode.com/00fly/springboot-hello/blob/main/src/main/java/com/fly/hello/web/RestPicController.java

bash 复制代码
git clone https://gitcode.com/00fly/springboot-hello.git

六、效果演示


有任何问题和建议,都可以向我提问讨论,大家一起进步,谢谢!

-over-

相关推荐
所待.383几秒前
JavaEE之线程初阶(上)
java·java-ee
Winston Wood4 分钟前
Java线程池详解
java·线程池·多线程·性能
手握风云-9 分钟前
数据结构(Java版)第二期:包装类和泛型
java·开发语言·数据结构
喵叔哟28 分钟前
重构代码中引入外部方法和引入本地扩展的区别
java·开发语言·重构
尘浮生34 分钟前
Java项目实战II基于微信小程序的电影院买票选座系统(开发文档+数据库+源码)
java·开发语言·数据库·微信小程序·小程序·maven·intellij-idea
不是二师兄的八戒1 小时前
本地 PHP 和 Java 开发环境 Docker 化与配置开机自启
java·docker·php
爱编程的小生1 小时前
Easyexcel(2-文件读取)
java·excel
带多刺的玫瑰1 小时前
Leecode刷题C语言之统计不是特殊数字的数字数量
java·c语言·算法
爱敲代码的憨仔1 小时前
《线性代数的本质》
线性代数·算法·决策树
yigan_Eins2 小时前
【数论】莫比乌斯函数及其反演
c++·经验分享·算法