本文介绍了如何获取单链表中元素的索引?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个课程:
SLList for methods(private SLElement _root)
SLElement for为列表创建新元素。 (public int _value; public SLElement _next)
我已经完成了添加方法:
I have two classes:
SLList for methods (private SLElement _root)
SLElement for creating new elements for the list. (public int _value; public SLElement _next)
I have finished the add-method:
public void Add(int value)
{
SLElement addNewElement = new SLElement();
addNewElement._value = value;
SLElement rootCopy = _root;
_root = addNewElement;
addNewElement._next = rootCopy;
Console.WriteLine(addNewElement._value);
}
所以现在我想要一个删除功能。我已经知道它删除了一个具有特定值的元素,但我希望它能删除具有特定索引的元素。如何找到列表中元素的索引?
So now I want a remove-function. I already got it working that it removes an element with a specific value, but I want it so that it removes an element with an specific index. How can I find out the index of the elements in my list?
推荐答案
这篇关于如何获取单链表中元素的索引?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!