AS3 如何反转向量表
AS3 How to reverse Vector List
我使用 setTimeout 进行服务器连接,当我连接时我想反转我的矢量列表。我如何反转我的矢量列表?
我的 Vector 变量 class
public class UriIterator
{
private var _availableAddresses: Vector.<SocketConnection> = new Vector.<SocketConnection>();
private var currentIndex:int = 0;
public function UriIterator(){
}
public function withAddress(host: String, port: int): UriIterator {
const a: SocketConnection = new SocketConnection(host, port);
_availableAddresses.push(a);
return this;
}
public function get next():SocketConnection {
var address = _availableAddresses[currentIndex];
currentIndex++;
if (currentIndex > _availableAddresses.length - 1)
currentIndex = 0;
return address;
}
}
并像那样初始化我的矢量列表
public static const urisToTry: UriIterator = new UriIterator()
urisToTry.withAddress("https:// 123", 1234);
urisToTry.withAddress("https:// 123", 1234);
urisToTry.withAddress("https:// 123", 1234);
urisToTry.withAddress("https:// 123", 1234);
reverse() 对向量的作用与对数组的作用相同。
我使用 setTimeout 进行服务器连接,当我连接时我想反转我的矢量列表。我如何反转我的矢量列表?
我的 Vector 变量 class
public class UriIterator
{
private var _availableAddresses: Vector.<SocketConnection> = new Vector.<SocketConnection>();
private var currentIndex:int = 0;
public function UriIterator(){
}
public function withAddress(host: String, port: int): UriIterator {
const a: SocketConnection = new SocketConnection(host, port);
_availableAddresses.push(a);
return this;
}
public function get next():SocketConnection {
var address = _availableAddresses[currentIndex];
currentIndex++;
if (currentIndex > _availableAddresses.length - 1)
currentIndex = 0;
return address;
}
}
并像那样初始化我的矢量列表
public static const urisToTry: UriIterator = new UriIterator()
urisToTry.withAddress("https:// 123", 1234);
urisToTry.withAddress("https:// 123", 1234);
urisToTry.withAddress("https:// 123", 1234);
urisToTry.withAddress("https:// 123", 1234);
reverse() 对向量的作用与对数组的作用相同。