简单随机数据算法

文章目录

一,需求概述

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

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

二,实现代码

借助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-

相关推荐
刚学HTML17 分钟前
leetcode 05 回文字符串
算法·leetcode
Yan.love30 分钟前
开发场景中Java 集合的最佳选择
java·数据结构·链表
椰椰椰耶33 分钟前
【文档搜索引擎】搜索模块的完整实现
java·搜索引擎
大G哥33 分钟前
java提高正则处理效率
java·开发语言
AC使者36 分钟前
#B1630. 数字走向4
算法
冠位观测者40 分钟前
【Leetcode 每日一题】2545. 根据第 K 场考试的分数排序
数据结构·算法·leetcode
智慧老师1 小时前
Spring基础分析13-Spring Security框架
java·后端·spring
lxyzcm1 小时前
C++23新特性解析:[[assume]]属性
java·c++·spring boot·c++23
古希腊掌管学习的神1 小时前
[搜广推]王树森推荐系统笔记——曝光过滤 & Bloom Filter
算法·推荐算法
qystca1 小时前
洛谷 P1706 全排列问题 C语言
算法