对于向量包,Go中是否有一个版本的removeElement函数,就像Java在其vector类中一样?

对于向量包,Go中是否有一个版本的removeElement函数,就像Java在其vector类中一样?,vector,go,Vector,Go,我正在将一些Java代码移植到Google的Go语言中,我转换了所有的代码,除了我在一个令人惊讶的平滑端口后只停留在一个部分。我的Go代码如下所示,我正在谈论的部分被注释掉: func main() { var puzzleHistory * vector.Vector; puzzleHistory = vector.New(0); var puzzle PegPuzzle; puzzle.InitPegPuzzle(3,2); puzzleHistory

我正在将一些Java代码移植到Google的Go语言中,我转换了所有的代码,除了我在一个令人惊讶的平滑端口后只停留在一个部分。我的Go代码如下所示,我正在谈论的部分被注释掉:

func main() {
    var puzzleHistory * vector.Vector;
    puzzleHistory = vector.New(0);
    var puzzle PegPuzzle;
    puzzle.InitPegPuzzle(3,2);
    puzzleHistory.Push(puzzle);

    var copyPuzzle PegPuzzle;
    var currentPuzzle PegPuzzle;

    currentPuzzle = puzzleHistory.At(0).(PegPuzzle);
    isDone := false;
    for !isDone {
        currentPuzzle = puzzleHistory.At(0).(PegPuzzle);
        currentPuzzle.findAllValidMoves();

        for i := 0; i < currentPuzzle.validMoves.Len(); i++ {
            copyPuzzle.NewPegPuzzle(currentPuzzle.holes, currentPuzzle.movesAlreadyDone);
            copyPuzzle.doMove(currentPuzzle.validMoves.At(i).(Move));
            // There is no function in Go's Vector that will remove an element like Java's Vector
            //puzzleHistory.removeElement(currentPuzzle);
            copyPuzzle.findAllValidMoves();
            if copyPuzzle.validMoves.Len() != 0 {
                puzzleHistory.Push(copyPuzzle);
            }
            if copyPuzzle.isSolutionPuzzle() {
                fmt.Printf("Puzzle Solved");
                copyPuzzle.show();
                isDone = true;
            }
        }
    }
}
func main(){
向量历史*vector.vector;
puzzleHistory=vector.New(0);
var难题;
拼图。初始拼图(3,2);
Push(拼图);
var复制难题;
var电流之谜;
currentPuzzle=puzzleHistory.At(0)。(PegPuzzle);
isDone:=假;
为了我!是的{
currentPuzzle=puzzleHistory.At(0)。(PegPuzzle);
currentPuzzle.findAllValidMoves();
对于i:=0;i

如果没有可用的版本,我相信没有。。。有人知道我将如何自己实现这样的事情吗?

Vector.Delete(I)怎么样?

现在go不支持通用的相等运算符。所以你必须写一些东西,在向量上迭代并删除正确的向量