简单轮询算法实现

2019-07-11
fun main(args: Array<String>) {
    val list = arrayListOf(0, 1, 2)

    var prevIndex = -1
    for (value in (1..7)) { // 执行7次测试
        val currentIndex = (prevIndex + 1) % list.size

        print("${list[currentIndex]} \t")

        prevIndex = currentIndex
    }
}

// 0 	1 	2 	0 	1 	2 	0 	
// TODO 加权