简单随机数据算法

文章目录

  • 一,需求概述
  • 二,实现代码
  • 三、测试代码
  • 四、测试结果
  • 五、源码传送
  • 六、效果演示

一,需求概述

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

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

二,实现代码

借助Queue实现FIFO

/**
 * 随机索引<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;
    }
}

三、测试代码

@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("------------成功退出------------");
        }
    }
}

四、测试结果


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

git clone https://gitcode.com/00fly/springboot-hello.git

六、效果演示

在这里插入图片描述


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

-over-

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/656082.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

AcWing 2568:树链剖分 ← 线段树+DFS

【题目来源】https://www.acwing.com/problem/content/2570/【题目描述】 给定一棵树&#xff0c;树中包含 n 个节点&#xff08;编号 1∼n&#xff09;&#xff0c;其中第 i 个节点的权值为 ai。 初始时&#xff0c;1 号节点为树的根节点。 现在要对该树进行 m 次操作&#xf…

力扣225. 用队列实现栈

Problem: 225. 用队列实现栈 文章目录 题目描述&#xff1a;思路Code 题目描述&#xff1a; 思路 1.对一个queue模拟栈的操作&#xff0c;同时用一个int类型的变量topElem记录每次每次队列队尾的元素&#xff08;也即是模拟stack中的stack的栈顶元素&#xff09;&#xff1b; 2…

Linux之单机项目部署

1、虚拟机&#xff08;VMware&#xff09;创建Linux系统 1.1、创建虚拟机 1.2、配置虚拟机IOS映射文件 1.3、虚拟机内部相关配置 等待加载即可&#xff0c;加载完后会弹出图形化界面&#xff0c;如图&#xff1a; 注意&#xff1a;一般我们做为管理员使用ROOT账号来操作&#x…

Tomcat端口配置

Tomcat是开源免费的服务器&#xff0c;其默认的端口为8080&#xff0c;本文讲述一下如何配置端口。 最后在浏览器中输入localhost:8888即可打开Tomcat界面

怎样打造一份个性化画册呢?我来教你

在这个数字化的时代&#xff0c;传统的照片已经不能满足我们对个性化回忆的需求。个性化画册&#xff0c;不仅能够承载我们的记忆&#xff0c;还能展现自我风格。今天&#xff0c;就让我来教你如何打造一份属于自己的个性化画册。 1.要制作电子杂志,首先需要选择一款适合自己的…

IT人的拖延——一放松就停不下来,耽误事?

拖延的表现 在我们的日常工作中&#xff0c;经常会面对这样一种情况&#xff1a;因为要做的Sprint ticket比较复杂或者长时间的集中注意力后&#xff0c;本来打算休息放松一下&#xff0c;刷刷剧&#xff0c;玩玩下游戏&#xff0c;但却一个不小心&#xff0c;没控制住时间&am…

【全开源】JAVA同城搬家系统源码小程序APP源码

JAVA同城搬家系统源码 特色功能&#xff1a; 强大的数据处理能力&#xff1a;JAVA提供了丰富的数据结构和算法&#xff0c;以及强大的并发处理能力&#xff0c;使得系统能够快速地处理大量的货物信息、司机信息、订单信息等&#xff0c;满足大规模物流的需求。智能路径规划&a…

常见5大开发进度盲点问题及解决方案

在软件开发项目中&#xff0c;识别并解决常见的进度管理盲点问题&#xff0c;对于确保项目按时、按预算、高质量完成至关重要。它直接关系到项目能否顺利进行&#xff0c;忽视任何一个问题&#xff0c;都可能导致项目延期、成本超支、质量下降&#xff0c;甚至项目失败。 因此&…

@ConfigurationProperties结合Nacos配置动态刷新之底层原理分析

Hello&#xff0c;我是大都督周瑜&#xff0c;本文给大家分析一下ConfigurationProperties结合Nacos配置动态刷新的底层原理&#xff0c;记得点赞、关注、分享哦&#xff01; 公众号&#xff1a;IT周瑜 应用背景 假如在Nacos中有Data ID为common.yml的配置项&#xff1a; m…

数智赋能内涝治理,四信城市排水防涝解决方案保障城市安全运行

由强降雨、台风造成城市低洼处出现大量积水、内涝的情况时有发生&#xff0c;给人们出行带来了极大不便和安全隐患&#xff0c;甚至危及群众生命财产安全。 为降低内涝造成的损失&#xff0c;一方面我们要大力加强城市排水基础设施的建设&#xff1b;另一方面要全面掌握城市内涝…

目标检测基础初步学习

目标检测&#xff08;Object Detection&#xff09; 目标检测任务说明 在动手学习深度学习中对目标检测任务有如下的描述。 图像分类任务中&#xff0c;我们假设图像中只有一个主要物体对象&#xff0c;我们只关注如何识别其类别。 然而&#xff0c;很多时候图像里有多个我们…

装饰模式:鸡腿堡

文章目录 UML类图目录结构Humburger.javaChickenBurger.javaCondiment.javaChuilli.javaLettuce.javaTest.java深度理解test怎么写 UML类图 目录结构 我们从指向最多的开始写 Humburger.java package zsms;public abstract class Humburger {protected String name;public S…

揭秘Tensor Core黑科技:如何让AI计算速度飞跃

揭秘 Tensor Core 底层&#xff1a;如何让AI计算速度飞跃 Tensor Core&#xff0c;加速深度学习计算的利器&#xff0c;专用于高效执行深度神经网络中的矩阵乘法和卷积运算&#xff0c;提升计算效率。 Tensor Core凭借混合精度计算与张量核心操作&#xff0c;大幅加速深度学习…

redis基本数据结构与应用

文章目录 概要String结构Hash结构List结构Set结构Zset结构bitmap位图类型geo地理位置类型其他常用命令 概要 redis常用的5种不同数据结构类型之间的映射如下&#xff1a; 结构类型结构存储的值结构的读写能力STRING可以是字符串、整数或者浮点数key-value形式&#xff1b;对整…

推荐系统学习笔记(四)--基于向量的召回

离散特征处理 离散特征&#xff1a;性别&#xff0c;国籍&#xff0c;英文单词&#xff0c;物品id&#xff0c;用户id 处理&#xff1a; 建立字典&#xff1a;eg&#xff1a;china 1 向量化&#xff1a;eg&#xff1a;one-hot /embedding&#xff08;低维稠密向量&#xf…

【漏洞复现】用友NC registerServlet JNDI 远程代码执行漏洞(XVE-2024-10248)

0x01 产品简介 用友NC是 用友软件股份有限公司开发的一套企业级管理软件系统。它是一个基于互联网的多层应用系统&#xff0c;旨在为中大型企业提供全面、集成的管理解决方案。是一种商业级的企业资源规划云平台&#xff0c;为企业提供全面的管理解决方案&#xff0c;包括财务…

数组-类似斐波那契数列,给出第一个和第二个结点值,求第n个值

一、问题描述 二、解题方法 可以采用两种方式&#xff1a; 方式1.使用递归&#xff0c;f(n)f(n-1)f(n-2); 当n1时&#xff0c;返回first&#xff1b;当n2时&#xff0c;返回second&#xff1b; 方式2.从第3个结点开始计算&#xff0c;当计算到第n个结点值的时候结束并返回计…

nginx编译安装手把手教学

编译安装nginx的第一步需要从nginx的官网找到nginx最新的稳定版本 下面这是官方网站的资源下载地址 https://nginx.org/en/download.html选中稳定版本点击右键——选择复制链接 在终端内使用wget指令官网下载地址&#xff0c;将nginx下载 使用wget指令下载 wget https://ng…

微服务项目搭建之技术选型

1、什么是微服务 Java微服务是一种架构风格&#xff0c;通过将单个Spring Boot应用程序拆分为一组小型、独立的Spring Boot服务来构建分布式系统。每个微服务都运行在自己的进程中&#xff0c;并使用轻量级通信机制&#xff08;如HTTP或消息队列&#xff09;来进行相互之间的通…

查询DQL

016条件查询之等量关系 条件查询语法格式 select ... from... where过滤条件;等于 select empno, ename from emp where sal3000;select job, sal from emp where enameFORD;select grade, losal, hisal from salgrade where grade 1;不等于 <> 或 ! selectempno,en…