一,需求概述
系统启动时,读取一组图片数据,通过接口返回给前台,要求:
- 图片随机
- 相邻图片不重复
二,实现代码
借助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退出,回车换行继续------------
五、源码传送
git clone https://gitcode.com/00fly/springboot-hello.git
六、效果演示
有任何问题和建议,都可以向我提问讨论,大家一起进步,谢谢!
-over-