本文整理汇总了C#中MyList类的典型用法代码示例。如果您正苦于以下问题:C# MyList类的具体用法?C# MyList怎么用?C# MyList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MyList类属于命名空间,在下文中一共展示了MyList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Test13Second
public void Test13Second()
{
MyList<MyPoint> set1 = new MyList<MyPoint>();
set1.Add(new MyPoint(8, 4));
set1.Add(new MyPoint(9, 6));
set1.Add(new MyPoint(1, 6));
set1.Add(new MyPoint(2, 6));
set1.Add(new MyPoint(5, 6));
set1.Add(new MyPoint(3, 6));
set1.Add(new MyPoint(6, 6));
set1.Add(new MyPoint(7, 5));
set1.Add(new MyPoint(8, 5));
set1.Add(new MyPoint(3, 7));
set1.Add(new MyPoint(6, 4));
set1.Add(new MyPoint(6, 5));
set1.Add(new MyPoint(2, 5));
ResultCollection2 res = Solution.CalculatePoints(set1).GetBestSet(4);
int val = res.ResultSet.Count;
int permute = 0;
Assert.IsTrue(val > 0);
int c = res.ResultSet[0].Count;
for (int i = 0; i < val; ++i)
{
Assert.AreEqual(c, res.ResultSet[i].Count, "Result sets are not all the same size");
permute += res.ResultSet[i].Permutations;
}
Assert.AreEqual(36, val);
Assert.AreEqual(864, permute);
}
示例2: Main
static void Main(string[] args)
{
MyList<string> test = new MyList<string>(7);
test.Add("lol0");
test.Add("lol2");
test.Add("lol1");
Console.WriteLine("lol0 "+test.GetElementByIndex(0));
Console.WriteLine("lol2 " + test.GetElementByIndex(1));
Console.WriteLine("lol1 " + test.GetElementByIndex(2));
Console.WriteLine("lol1 " + test.GetLastElement());
test.RemoveLastElement();
Console.WriteLine("lol2 " + test.GetLastElement());
Console.WriteLine("2 "+test.getCount());
test.RemoveFirstElement();
Console.WriteLine("lol2 "+test.GetLastElement());
Console.WriteLine("1 "+test.getCount());
test.InsertElementAt(0, "lol2");
Console.WriteLine("lol2 " + test.GetLastElement());
test.InsertElementAt(1, "lol3");
test.InsertElementAt(1, "lol4");
Console.WriteLine("4 " +test.getCount());
test.RemoveLastElement();
Console.WriteLine("lol3 "+test.GetLastElement());
test.RemoveLastElement();
Console.WriteLine("lol4 " + test.GetLastElement());
foreach (var item in test)
{
Console.WriteLine(item);
}
Console.Read();
}
示例3: testAs4
public void testAs4()
{
var x = new MyList();
AssertNotNull(AsIEnumerable(x));
AssertNotNull(AsICollection(x));
AssertNotNull(AsIList(x));
}
示例4: Main
static void Main(string[] args)
{
MyList<int> mylist = new MyList<int>();
mylist.Add(213);
mylist.Add(13);
mylist.Add(1);
mylist.Add(23);
mylist.Insert(1,2);
mylist.RemoveAt(4);
mylist[0] = 100;
for (int i = 0; i < mylist.Count; i++)
{
//Console.WriteLine(mylist.GetItem(i));
Console.WriteLine(mylist[i]);
}
Console.WriteLine(mylist.IndexOf(13));
Console.WriteLine(mylist.LastIndexOf(2));
mylist.Sort();
for (int i = 0; i < mylist.Count; i++)
{
//Console.WriteLine(mylist.GetItem(i));
Console.WriteLine(mylist[i]);
}
Console.ReadKey();
}
示例5: A43_Load
private void A43_Load(object sender, EventArgs e)
{
if (this.DesignMode)
{
return;
}
MyList<string> list = new MyList<string>();
list.Add(isPT() ? "Gasolina" : "Nafta");
list.Add(isPT() ? "Diesel" : "Diesel");
list.Add(isPT() ? "GLP/ Gas Licuado de Petróleo más nafta" : "GLP/Gás de petróleo liquefeito mais gasolina");
list.Add(isPT() ? "GNV/Gás Natural Veicular mais gasolina" : "GNC/ Gas Natural Comprimido más nafta");
list.Add(isPT() ? "GNV/Gás Natural Veicular" : "GNC/ Gas natural Comprimido");
list.Add(isPT() ? "GNV/Gás Natural Veicular mais diesel" : "GNC/ Gas Natural Comprimido másdiesel");
list.Add(isPT() ? "Flex-fuel total flex: etanol e gasolina ou uma mistura dos dois" : "Combustible flexible (Flex Fuel)/vehículo totalflex: etanol y nafta ouna mezcla delas anteriores");
list.Add(isPT() ? "Biodiesel" : "Biodiesel");
list.Add(isPT() ? "Bioetanol" : "Bioetanol");
list.Add(isPT() ? "Motor totalmente elétrico" : "Transmisióntotalmente eléctrica");
list.Add(isPT() ? "Motor híbrido combinado com diesel" : "Motor híbrido combinado con diesel");
list.Add(isPT() ? "Motor híbrido combinado com gasolina" : "Motor híbrido combinado con nafta");
list.Add(isPT() ? "Célula de combustível" : "Pila de combustible");
MyList<string> listVisiveis = new MyList<string>();
listVisiveis.AddRange(new string[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14" });
class_A.Lista = list;
class_A.Visiveis = listVisiveis;
}
示例6: testIs4
public void testIs4()
{
var x = new MyList();
AssertTrue(IsIEnumerable(x));
AssertTrue(IsICollection(x));
AssertTrue(IsIList(x));
}
示例7: should_Add_Single_Item_To_MyList_Instance
public void should_Add_Single_Item_To_MyList_Instance()
{
var myList = new MyList();
myList.Add(1);
Assert.AreEqual(1,myList.Count);
Assert.AreEqual(1,myList.Capacity);
}
示例8: A37_Load
private void A37_Load(object sender, EventArgs e)
{
if (this.DesignMode)
{
return;
}
string msg = isPT() ? String.Format("Com que tipo de gasolina o(a) Sr(a). geralmente abastece seu {0}?", rowCurrent["A4_A_NOME"]) : String.Format("¿Con qué tipo de nafta reabastece normalmente su {0}?", rowCurrent["A4_A_NOME"]);
Label3.Text = msg;
MyList<string> list = new MyList<string>();
list.Add(isPT() ? "Petrobras: 101.5 octanas" : "Petrobras: 101.5 octanos");
list.Add(isPT() ? "YPF fangio XXI: 98 octanas" : "YPF fangio XXI: 98 octanos");
list.Add(isPT() ? "SHELL V-Power: 97,5 octanas" : "SHELL V-Power: 97.5 octanos");
list.Add(isPT() ? "SUPER: 93,5 a 95 octanas" : "SUPER: 93.5 a 95 octanos");
list.Add(isPT() ? "Comum: 83 a 85 octanas" : "Común: 83 a85 octanos");
list.Add(isPT() ? "Gasolina comum: 87 octanas" : "Nafta común: 87 octanos");
list.Add(isPT() ? "Gasolina Aditiva Supra: 87 octanas (+ aditivos)" : "Nafta Aditiva Supra: 87 octanos (+ aditivitos)");
list.Add(isPT() ? "Gasolina Premium: 91 octanas" : "Nafta Premium: 91 octanos");
list.Add(isPT() ? "Gasolina Podium: 95 octanas" : "NaftaPodium: 95 octanos");
MyList<string> listVisiveis = new MyList<string>();
if (isPT())
{
listVisiveis.AddRange(new string[] { "6", "7", "8", "9"});
}
else
{
listVisiveis.AddRange(new string[] { "1", "2", "3", "4", "5"});
}
//listVisiveis.Shuffle();
class_A.Lista = list;
class_A.Visiveis = listVisiveis;
}
示例9: OutputResults2
//public void OutputResults(ResultCollection res)
//{
// int count = 0;
// foreach (Results r in res.ResultSet)
// {
// Console.WriteLine("Result set {0}", ++count);
// Console.WriteLine("Permutuations: {0}", r.Permutations);
// foreach (Line l in r.Lines)
// {
// Console.Write("Line: ");
// foreach (MyPoint p in l.Points)
// {
// Console.Write("({0}, {1}) ", p.X, p.Y);
// }
// Console.WriteLine();
// }
// Console.WriteLine();
// }
// Console.Read();
//}
public void OutputResults2(MyList<MyPoint> set1, ResultCollection2 res)
{
int count = 0;
for (int k = 0; k < res.ResultSet.Count; k++)
{
Results2 r = res.ResultSet[k];
Console.WriteLine("Result set {0}", ++count);
Console.WriteLine("Permutuations: {0}", r.Permutations);
int c = r.Count;
for (int j = 0; j < c; j++)
{
ItemSet l = r.GetLine(j);
if (r.Count == 1)
{
Console.WriteLine("Emergency");
}
Console.Write("Line: ");
for (int i = 0; i < l.Count; i++)
{
Console.Write("({0}, {1}) ", l.GetItem(set1, i).X, l.GetItem(set1, i).Y);
}
Console.WriteLine();
}
Console.WriteLine();
}
Console.Read();
}
示例10: GetCastling
public MyList<Position> GetCastling()
{
MyList<Position> castling = new MyList<Position>();
Figure fig;
int x = Position.GetX();
if (ismoved())
return castling;
Side oppside = GetEnemySide();
int ypos = (this.Side == Side.White) ? 1 : 8;
if (chessfield.isDangerPosition(oppside, Position))
return castling;
fig = chessfield.GetFigureAt(new Position(1, ypos));
if (fig != null &&
!chessfield.isDangerPosition(oppside, new Position(x-1,ypos)) &&
!chessfield.isDangerPosition(oppside, new Position(x - 2, ypos)) &&
!chessfield.isDangerPosition(oppside, new Position(x - 3, ypos)) &&
!chessfield.isDangerPosition(oppside, new Position(x, ypos)) &&
!fig.ismoved() &&
chessfield.GetFigureAt(new Position(2, ypos)) == null &&
chessfield.GetFigureAt(new Position(3, ypos)) == null &&
chessfield.GetFigureAt(new Position(4, ypos)) == null)
castling.Add(fig.Position);
fig = chessfield.GetFigureAt(new Position(8, ypos));
if (fig != null &&
!chessfield.isDangerPosition(oppside, new Position(x + 1, ypos)) &&
!chessfield.isDangerPosition(oppside, new Position(x + 2, ypos)) &&
!chessfield.isDangerPosition(oppside, new Position(x, ypos)) &&
!fig.ismoved() &&
chessfield.GetFigureAt(new Position(7, ypos)) == null &&
chessfield.GetFigureAt(new Position(6, ypos)) == null)
castling.Add(fig.Position);
return castling;
}
示例11: Main
static void Main(string[] args)
{
MyList<int> List = new MyList<int>();
List.AddElem(10);
List.AddElem(15);
List.AddElem(20);
}
示例12: Main
public static void Main(String[] args)
{
Console.WriteLine ("Fill MyList object with content\n");
MyList l = new MyList();
for (int x=0; x< 10; x++)
{
Console.WriteLine (x);
l.Add (x);
} // end for
Console.WriteLine("\nSerializing object graph to file {0}", FILENAME);
Stream outFile = File.Open(FILENAME, FileMode.Create, FileAccess.ReadWrite);
BinaryFormatter outFormat = new BinaryFormatter();
outFormat.Serialize(outFile, l);
outFile.Close();
Console.WriteLine("Finished\n");
Console.WriteLine("Deserializing object graph from file {0}", FILENAME);
Stream inFile = File.Open(FILENAME, FileMode.Open, FileAccess.Read);
BinaryFormatter inFormat = new BinaryFormatter();
MyList templist = (MyList)inFormat.Deserialize(inFile);
Console.WriteLine ("Finished\n");
foreach (MyListItem mli in templist)
{
Console.WriteLine ("List item number {0}, square root {1}", mli.Number, mli.Sqrt);
} //foreach
inFile.Close();
} // end main
示例13: Main
static void Main(string[] args)
{
MyList<int> generic_int = new MyList<int>();
generic_int.Add(-1);
generic_int.Add(2);
generic_int.Add(3);
MyList<float> genfloat = new MyList<float>();
genfloat.Add(2.45f);
genfloat.Add(2.46f);
genfloat.Add(2.47f);
genfloat.Add(2.48f);
genfloat.Add(2.49f);
Console.WriteLine("Друкуемо раз:");
foreach (var item in generic_int)
{
Console.WriteLine(item);
}
Console.WriteLine("Друкуемо два:");
foreach (var item in genfloat)
{
Console.WriteLine(item);
}
Console.WriteLine(generic_int.IndexOf(2));
generic_int.Remove(2);
Console.WriteLine(generic_int.IndexOf(2));
Console.WriteLine("Писля удаления:");
foreach (var item in generic_int)
{
Console.WriteLine(item);
}
}
示例14: GetInMoveAttacks
/// <summary>
/// Вернет список бьющихся фигур на проходе
/// </summary>
/// <returns></returns>
public MyList<Position> GetInMoveAttacks()
{
int delta = (Side == Side.Black) ? +1 : -1;
Position pos;
Side oppside = GetEnemySide();
Figure fig;
MyList<Position> moves = new MyList<Position>();
foreach (Position attack in GetAttacks())
{
try{
pos = new Position(attack.GetX(), attack.GetY() + delta);
fig = chessfield.GetFigureAt(pos);
if (fig != null && fig.GetFigureType() == FigureTypes.Pawn &&
fig.Side == oppside &&
chessfield.GetlastMoved(oppside) == fig)
moves.Add(pos);
{
}
}
catch {}
}
return moves;
}
示例15: Test16First
public void Test16First()
{
MyList<MyPoint> set1 = new MyList<MyPoint>();
set1.Add(new MyPoint(1, 6));
set1.Add(new MyPoint(2, 6));
set1.Add(new MyPoint(5, 6));
set1.Add(new MyPoint(3, 6));
set1.Add(new MyPoint(2, 5));
set1.Add(new MyPoint(3, 5));
set1.Add(new MyPoint(5, 5));
set1.Add(new MyPoint(3, 4));
set1.Add(new MyPoint(3, 7));
set1.Add(new MyPoint(6, 4));
set1.Add(new MyPoint(6, 5));
set1.Add(new MyPoint(6, 6));
set1.Add(new MyPoint(7, 5));
set1.Add(new MyPoint(8, 5));
set1.Add(new MyPoint(8, 4));
set1.Add(new MyPoint(9, 6));
ResultCollection2 res = Solution.CalculatePoints(set1);
int val = res.ResultSet.Count;
int permute = 0;
Assert.IsTrue(val > 0);
int c = res.ResultSet[0].Count;
for (int i = 0; i < val; ++i)
{
Assert.AreEqual(c, res.ResultSet[i].Count);
permute += res.ResultSet[i].Permutations;
}
Assert.AreEqual(8, val);
Assert.AreEqual(192, permute);
}