欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程资源 > 编程问答 >内容正文

编程问答

在java中图片随机播放_java-以相同顺序随机播放多个文件

发布时间:2023/12/9 编程问答 36 豆豆
生活随笔 收集整理的这篇文章主要介绍了 在java中图片随机播放_java-以相同顺序随机播放多个文件 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

接下来仅使用基本的bash命令.原则是:

>生成随机顺序(数字)

>按此顺序订购所有文件

编码

#!/bin/bash

case "$#" in

0) echo "Usage: $0 files....." ; exit 1;;

esac

ORDER="./.rand.$$"

trap "rm -f $ORDER;exit" 1 2

count=$(grep -c '^' "$1")

let odcount=$(($count * 4))

paste -d" " $ORDER

#if your system has the "shuf" command you can replace the above 3 lines with a simple

#seq -w $count | shuf > $ORDER

for file in "$@"

do

paste -d' ' $ORDER $file | sort -k1n | cut -d' ' -f2- > "$file.rand"

done

echo "the order is in the file $ORDER" # remove this line

#rm -f $ORDER # and uncomment this

# if dont need preserve the order

paste -d " " *.rand #remove this line - it is only for showing test result

从输入文件中:

A B C

--------

a1 a2 a3

b1 b2 b3

c1 c2 c3

d1 d2 d3

e1 e2 e3

f1 f2 f3

g1 g2 g3

h1 h2 h3

i1 i2 i3

j1 j2 j3

将使用下一个示例内容制作A.rand B.rand C.rand

g1 g2 g3

e1 e2 e3

b1 b2 b3

c1 c2 c3

f1 f2 f3

j1 j2 j3

d1 d2 d3

h1 h2 h3

i1 i2 i3

a1 a2 a3

真实测试-用25k行生成50个文件

line="Consequatur qui et qui. Mollitia expedita aut excepturi modi. Enim nihil et laboriosam sit a tenetur."

for n in $(seq -w 50)

do

seq -f "$line %g" 25000 >file.$n

done

运行脚本

bash sorter.sh file.??

结果在我的笔记本上

real 1m13.404s

user 0m56.127s

sys 0m5.143s

总结

以上是生活随笔为你收集整理的在java中图片随机播放_java-以相同顺序随机播放多个文件的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。