本文整理汇总了C#中LinkedList.Get方法的典型用法代码示例。如果您正苦于以下问题:C# LinkedList.Get方法的具体用法?C# LinkedList.Get怎么用?C# LinkedList.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LinkedList
的用法示例。
在下文中一共展示了LinkedList.Get方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestLinkedListOperators
public void TestLinkedListOperators()
{
var lst = new LinkedList<int>();
lst.Append(1);
lst.Append(2);
lst.Append(4);
lst.Append(5);
lst.Insert(2, 3);
Assert.AreEqual(lst.Get(2).Content, 3);
Assert.AreEqual(lst.Get(3).Content, 4);
lst.Remove(0);
Assert.AreEqual(lst.Get(0).Content, 2);
Assert.AreEqual(lst.ToString(), "2 3 4 5");
}
示例2: GetLastItemTest
[TestMethod] // получение последнего элемента
public void GetLastItemTest()
{
LinkedList<object> data = new LinkedList<object>();
data.Append(4);
data.Append(2);
data.Get(1);
}
示例3: GetFirstItemTest
[TestMethod] // получение первого элемента
public void GetFirstItemTest()
{
LinkedList<object> data = new LinkedList<object>();
data.Append(8);
data.Append(10);
data.Get(0);
}
示例4: buildRichTextRuns
public void buildRichTextRuns(LinkedList pStyles, LinkedList cStyles, String RunRawText){
// Handle case of no current style, with a default
if(pStyles.Count == 0 || cStyles.Count == 0) {
_rtRuns = new RichTextRun[1];
_rtRuns[0] = new RichTextRun(this, 0, RunRawText.Length);
} else {
// Build up Rich Text Runs, one for each
// character/paragraph style pair
Vector rtrs = new Vector();
int pos = 0;
int curP = 0;
int curC = 0;
int pLenRemain = -1;
int cLenRemain = -1;
// Build one for each run with the same style
while(pos <= RunRawText.Length && curP < pStyles.Count && curC < cStyles.Count) {
// Get the Props to use
TextPropCollection pProps = (TextPropCollection)pStyles.Get(curP);
TextPropCollection cProps = (TextPropCollection)cStyles.Get(curC);
int pLen = pProps.GetCharactersCovered();
int cLen = cProps.GetCharactersCovered();
// Handle new pass
bool freshSet = false;
if(pLenRemain == -1 && cLenRemain == -1) { freshSet = true; }
if(pLenRemain == -1) { pLenRemain = pLen; }
if(cLenRemain == -1) { cLenRemain = cLen; }
// So we know how to build the eventual run
int RunLen = -1;
bool pShared = false;
bool cShared = false;
// Same size, new styles - neither shared
if(pLen == cLen && freshSet) {
RunLen = cLen;
pShared = false;
cShared = false;
curP++;
curC++;
pLenRemain = -1;
cLenRemain = -1;
} else {
// Some sharing
// See if we are already in a shared block
if(pLenRemain < pLen) {
// Existing shared p block
pShared = true;
// Do we end with the c block, or either side of it?
if(pLenRemain == cLenRemain) {
// We end at the same time
cShared = false;
RunLen = pLenRemain;
curP++;
curC++;
pLenRemain = -1;
cLenRemain = -1;
} else if(pLenRemain < cLenRemain) {
// We end before the c block
cShared = true;
RunLen = pLenRemain;
curP++;
cLenRemain -= pLenRemain;
pLenRemain = -1;
} else {
// We end after the c block
cShared = false;
RunLen = cLenRemain;
curC++;
pLenRemain -= cLenRemain;
cLenRemain = -1;
}
} else if(cLenRemain < cLen) {
// Existing shared c block
cShared = true;
// Do we end with the p block, or either side of it?
if(pLenRemain == cLenRemain) {
// We end at the same time
pShared = false;
RunLen = cLenRemain;
curP++;
curC++;
pLenRemain = -1;
cLenRemain = -1;
} else if(cLenRemain < pLenRemain) {
// We end before the p block
pShared = true;
RunLen = cLenRemain;
curC++;
pLenRemain -= cLenRemain;
cLenRemain = -1;
} else {
//.........这里部分代码省略.........