本文整理汇总了C#中System.Collections.Generic.List.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# System.Collections.Generic.List.Contains方法的具体用法?C# System.Collections.Generic.List.Contains怎么用?C# System.Collections.Generic.List.Contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Generic.List
的用法示例。
在下文中一共展示了System.Collections.Generic.List.Contains方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShouldProvideCurrentItems
public void ShouldProvideCurrentItems()
{
Window window = LaunchPetShopWindow();
var comboBox = window.Find<EditableComboBox>("petTypeInput");
var items = new System.Collections.Generic.List<string>(comboBox.Items);
Assert.True(items.Contains("PetType[Rabbit]"));
Assert.True(items.Contains("PetType[Dog]"));
}
示例2: createMinimumSpan
public System.Collections.Generic.List<Edge> createMinimumSpan()
{
Vector2 start = Vector2.zero;
//Choose a point to start with
foreach(Vector2 point in this.allPoints)
{
//This just pulls the first point. Do I need to do differently? If so I can put it here.
start = point;
break;
}//for each
System.Collections.Generic.List<Vector2> finished = new System.Collections.Generic.List<Vector2>();
finished.Add(start);
int numFinished = 1;
//Reapeat until each vert in this.allPoints has been added to "finished"
while(numFinished < this.allPoints.Count)
{
Vector2 source = allPoints[0];
Vector2 destWithMinimalWeight = allPoints[1];
float currentBestWeight = float.MaxValue;
foreach(Vector2 point in finished)
{
//1. For each point in "finished"
//Check all the other points and check to see if they're closer than the current best one
foreach (Vector2 dest in this.allPoints)
{
//If the dest is already in "finished", just ignore it and keep going
if(finished.Contains(dest))
{
continue; // go to the next one
}
float dist = Vector2.Distance(point, dest);
if(dist < currentBestWeight && dist > 0)
{
//If they are closer than the current best weight, update the current best
currentBestWeight = dist;
destWithMinimalWeight = dest;
source = point;
}//if
}//for
}//for each
//2. Connect the source to the destWithMinimalPoint by making an edge
Edge theNewEdge = new Edge(source, destWithMinimalWeight);
edges.Add(theNewEdge);
//3. Add the destination to "finished"
finished.Add(destWithMinimalWeight);
numFinished++;
}//while
return edges;
}
示例3: FindPhaseAngleOfTarget
public static double FindPhaseAngleOfTarget(Vessel thisVessel, string TargetName)
{
//0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
string[] BODIES = {"Sun","Kerbin", "Mun", "Minmus", "Moho", "Eve", "Duna", "Ike", "Jool", "Laythe", "Vall", "Bop", "Tylo", "Gilly", "Pol", "Dres", "Eeloo"};
CelestialBody body = FlightGlobals.Bodies[0];
for (int i=0;i<BODIES.Length;i++)
{
//if (FlightGlobals.Bodies[i].GetName() == FlightGlobals.fetch.VesselTarget.GetName ())
if (FlightGlobals.Bodies[i].GetName() == TargetName)
{
body = FlightGlobals.Bodies[i];
break;
}
}
System.Collections.Generic.List<CelestialBody> parentBodies = new System.Collections.Generic.List<CelestialBody>();
CelestialBody parentBody = thisVessel.mainBody;
while (true)
{
if (parentBody == body)
{
return double.NaN;
}
parentBodies.Add(parentBody);
if (parentBody == Planetarium.fetch.Sun)
{
break;
}
else
{
parentBody = parentBody.referenceBody;
}
}
while (!parentBodies.Contains(body.referenceBody))
{
body = body.referenceBody;
}
Orbit orbit = thisVessel.orbit;
while (orbit.referenceBody != body.referenceBody)
{
orbit = orbit.referenceBody.orbit;
}
// Calculate the phase angle
double ut = Planetarium.GetUniversalTime();
Vector3d vesselPos = orbit.getRelativePositionAtUT(ut);
Vector3d bodyPos = body.orbit.getRelativePositionAtUT(ut);
double phaseAngle = (Math.Atan2(bodyPos.y, bodyPos.x) - Math.Atan2(vesselPos.y, vesselPos.x)) * (180.0 / Math.PI);
return (phaseAngle < 0) ? phaseAngle + 360 : phaseAngle;
}
示例4: CalculateDefines
public string CalculateDefines(string addDefines, string removeDefines)
{
var addArray = addDefines.Trim(';').Split(';');
var removeArray = removeDefines.Trim(';').Split(';');
var list = new System.Collections.Generic.List<string>();
foreach (var a in addArray)
{
if (!list.Contains(a))
{
list.Add(a);
}
}
foreach (var r in removeArray)
{
if (list.Contains(r))
{
list.Remove(r);
}
}
return string.Join(";", list.ToArray());
}
示例5: PartOfHex
bool PartOfHex(string value)
{
if (value.Length == 7) { return false; }
if (value.Length + la.val.Length > 7) { return false; }
System.Collections.Generic.List<string> hexes = new System.Collections.Generic.List<string>(new string[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "a", "b", "c", "d", "e", "f" });
foreach (char c in la.val)
{
if (!hexes.Contains(c.ToString()))
{
return false;
}
}
return true;
}
示例6: solution0
public int solution0(int[] A)
{
var l = new System.Collections.Generic.List<int>();
for (int i = 0; i < A.Length; i++)
{
if (l.Contains(A[i]))
{
l.Remove(A[i]);
}
else
{
l.Add(A[i]);
}
}
return l.FirstOrDefault();
}
示例7: MergeBanklogs
public void MergeBanklogs(Banklog[] b)
{
int i;
System.Collections.Generic.List<Banklog> t = new System.Collections.Generic.List<Banklog>(this.banklog);
if (!System.Object.ReferenceEquals(this, b))
{
for (i = 0; i < b.Length; i++)
{
if (!t.Contains(b[i]))
t.Add(b[i]);
}
}
this.banklog = t.ToArray();
}
示例8: addCustomerInfo
public void addCustomerInfo(string newName, Texture newTexture)
{
//if(PhotonNetwork.playerName == targetPlayer)
// {
// add the conversationName to the list
System.Collections.Generic.List<string> nameList = new System.Collections.Generic.List<string>(customerNames);
if(!nameList.Contains(newName))
nameList.Add(newName);
customerNames = nameList.ToArray();
// add the display text to the textlist
System.Collections.Generic.List<Texture> textureList = new System.Collections.Generic.List<Texture>(customerImages);
if(!textureList.Contains(newTexture))
textureList.Add(newTexture);
customerImages = textureList.ToArray();
// }
}
示例9: addCallToNPCList
public void addCallToNPCList(string buttonDisplayText, string conversationName, string playerName)
{
if (PhotonNetwork.playerName == playerName) {
// add the conversationName to the list
System.Collections.Generic.List<string> conversationList = new System.Collections.Generic.List<string> (dialogueNames);
if (!conversationList.Contains (conversationName))
conversationList.Add (conversationName);
dialogueNames = conversationList.ToArray ();
// add the display text to the textlist
System.Collections.Generic.List<string> textList = new System.Collections.Generic.List<string> (dialogueDisplayText);
if (!textList.Contains (buttonDisplayText))
textList.Add (buttonDisplayText);
dialogueDisplayText = textList.ToArray ();
}
}
示例10: addDocument
public void addDocument(GameObject toBeAdd)
{
System.Collections.Generic.List<GameObject> list = new System.Collections.Generic.List<GameObject>(documents);
if(!list.Contains(toBeAdd))
list.Add(toBeAdd);
documents = list.ToArray();
// foreach(GameObject a in documents)
// print (a.name);
// re allocate the position of documents
if(documents.Length != 0)
for(int i =0; i < documents.Length; i ++)
{
documents[i].transform.parent = fileModeObj.transform;
documents[i].transform.localPosition = new Vector3(-0.2275543f +i*0.35f,0,-0.03671265f);
}
}
示例11: convertCharArrayToTex
private static Texture2D convertCharArrayToTex(System.Collections.Generic.List<KSF_CharArray> chArray, int length, Color color)
{
Texture2D tex = new Texture2D(length - 4, 7);
int offSet = 0;
System.Collections.Generic.List<Vector2> pxMap = new System.Collections.Generic.List<Vector2>();
pxMap.Clear();
foreach (KSF_CharArray ka in chArray)
{
foreach (Vector2 px in ka.pixelList)
{
pxMap.Add(new Vector2(px.x + offSet, px.y));
}
offSet += ka.charWidth;
}
for (int y = 0; y < tex.height; y++)
{
for (int x = 0; x < tex.width; x++)
{
if (pxMap.Contains(new Vector2(x, y)))
{
tex.SetPixel(x, y, Color.black);
}
else
{
tex.SetPixel(x, y, color);
}
}
}
return tex;
}
示例12: ProcessEmbeddedFiles
/// <summary>
/// Reads in the embedded files from an assembly an processes them into
/// the virtual filesystem.
/// </summary>
/// <param name="assemblyName">The name of the <see cref="System.Reflection.Assembly"/> to load and process.</param>
/// <exception cref="System.ArgumentNullException">
/// Thrown if <paramref name="assemblyName" /> is <see langword="null" />.
/// </exception>
/// <exception cref="System.ArgumentOutOfRangeException">
/// Thrown if <paramref name="assemblyName" /> is <see cref="System.String.Empty" />.
/// </exception>
/// <exception cref="System.IO.FileNotFoundException">
/// Thrown if the <see cref="System.Reflection.Assembly"/> indicated by
/// <paramref name="assemblyName" /> is not found.
/// </exception>
/// <remarks>
/// <para>
/// The <paramref name="assemblyName" /> will be passed to <see cref="System.Reflection.Assembly.Load(string)"/>
/// so the associated assembly can be processed. If the assembly is not
/// found, a <see cref="System.IO.FileNotFoundException"/> is thrown.
/// </para>
/// <para>
/// Once the assembly is retrieved, it is queried for <see cref="TVA.Web.Hosting.EmbeddedResourceFileAttribute"/>
/// instances. For each one found, the associated resources are processed
/// into virtual files that will be stored in
/// <see cref="TVA.Web.Hosting.EmbeddedResourcePathProvider.Files"/>
/// for later use.
/// </para>
/// </remarks>
/// <seealso cref="TVA.Web.Hosting.EmbeddedResourcePathProvider" />
/// <seealso cref="TVA.Web.Hosting.EmbeddedResourcePathProvider.Initialize" />
protected virtual void ProcessEmbeddedFiles(string assemblyName)
{
if (string.IsNullOrEmpty(assemblyName))
throw new ArgumentNullException("assemblyName");
Assembly assembly = Assembly.LoadFrom(FilePath.GetAbsolutePath(assemblyName));
// Get the embedded files specified in the assembly; bail early if there aren't any.
EmbeddedResourceFileAttribute[] attribs = (EmbeddedResourceFileAttribute[])assembly.GetCustomAttributes(typeof(EmbeddedResourceFileAttribute), true);
if (attribs.Length == 0)
{
return;
}
// Get the complete set of embedded resource names in the assembly; bail early if there aren't any.
System.Collections.Generic.List<String> assemblyResourceNames = new System.Collections.Generic.List<string>(assembly.GetManifestResourceNames());
if (assemblyResourceNames.Count == 0)
{
return;
}
foreach (EmbeddedResourceFileAttribute attrib in attribs)
{
// Ensure the resource specified actually exists in the assembly
if (!assemblyResourceNames.Contains(attrib.ResourcePath))
{
continue;
}
// Map the path into the web application
string mappedPath;
try
{
mappedPath = System.Web.VirtualPathUtility.ToAbsolute(MapResourceToWebApplication(attrib.ResourceNamespace, attrib.ResourcePath));
}
catch (ArgumentNullException)
{
continue;
}
catch (ArgumentOutOfRangeException)
{
continue;
}
// Create the file and ensure it's unique
EmbeddedResourceVirtualFile file = new EmbeddedResourceVirtualFile(mappedPath, assembly, attrib.ResourcePath);
if (this.Files.Contains(file.VirtualPath))
{
continue;
}
// The file is unique; add it to the filesystem
this.Files.Add(file);
}
}
示例13: stackThrustPredictPic
/// <summary>
/// This will return an image of the specified size with the thrust graph for this nozzle
/// Totally jacked the image code from the wiki http://wiki.kerbalspaceprogram.com/wiki/Module_code_examples, with some modifications
///
///
/// </summary>
/// <param name="imgH">Hight of the desired output, in pixels</param>
/// <param name="imgW">Width of the desired output, in pixels</param>
/// <param name="burnTime">Chart for burn time in seconds</param>
/// <returns></returns>
public static Texture2D stackThrustPredictPic(int imgH, int imgW, int burnTime, FloatCurve atmoCurve, AdvSRBNozzle nozzle)
{
//First we set up the analyzer
//Step 1: Figure out fuel sources
nozzle.FuelStackSearcher(nozzle.FuelSourcesList);
//Step 2: Set up mass variables
float stackTotalMass = 0f;
stackTotalMass = nozzle.fullStackFuelMass;
float remStackFuel = nozzle.fullStackFuelMass;
//stackTotalMass = CalcStackWetMass(FuelSourcesList, stackTotalMass);
//float[] segmentFuelArray = new float[nozzle.FuelSourcesList.Count];
int i = 0;
//foreach (Part p in nozzle.FuelSourcesList)
//{
// segmentFuelArray[i] = p.GetResourceMass();
// i++;
//}
//float stackCurrentMass = stackTotalMass;
//Now we set up the image maker
Texture2D image = new Texture2D(imgW, imgH);
int graphXmin = 19;
int graphXmax = imgW - 20;
int graphYmin = 19;
//Step 3: Set Up color variables
Color brightG = Color.black;
brightG.r = .3372549f;
brightG.g = 1;
Color mediumG = Color.black;
mediumG.r = 0.16862745f;
mediumG.g = .5f;
Color lowG = Color.black;
lowG.r = 0.042156863f;
lowG.g = .125f;
Color MassColor = Color.blue;
Color ThrustColor = Color.cyan;
Color ExtraThrustColor = Color.yellow;
//Step 4: Define text arrays
KSF_CharArrayUtils.populateCharArrays();
//Step 5a: Define time markings (every 10 seconds gets a verticle line)
System.Collections.Generic.List<int> timeLines = new System.Collections.Generic.List<int>();
double xScale = (imgW - 40) / (double)burnTime;
//print("xScale: " + xScale);
calcTimeLines((float)burnTime, 10, timeLines, (float)xScale, 20);
//Step 5b: Define vertical line markings (9 total to give 10 sections)
System.Collections.Generic.List<int> horzLines = new System.Collections.Generic.List<int>();
calcHorizLines(imgH - graphYmin, horzLines, 9, 20);
//Step 6: Clear the background
//Set all the pixels to black. If you don't do this the image contains random junk.
for (int y = 0; y < image.height; y++)
{
for (int x = 0; x < image.width; x++)
{
image.SetPixel(x, y, Color.black);
}
}
//Step 7a: Draw Time Lines
for (int y = 0; y < image.height; y++)
{
for (int x = 0; x < image.width; x++)
{
if (timeLines.Contains(x) && y > graphYmin)
image.SetPixel(x, y, lowG);
}
}
//Step 7b: Draw Vert Lines
for (int y = 0; y < image.height; y++)
{
for (int x = 0; x < image.width; x++)
{
if (horzLines.Contains(y) && x < graphXmax && x > graphXmin)
image.SetPixel(x, y, lowG);
}
}
//Step 7c: Draw Bounding Lines
for (int y = 0; y < image.height; y++)
{
for (int x = 0; x < image.width; x++)
{
if ((x == graphXmin | x == graphXmax) && (y > graphYmin | y == graphYmin))
//.........这里部分代码省略.........
示例14: OnMenuValidate
/// <summary>
/// Handler for validating the current selection.
/// </summary>
internal virtual void OnMenuValidate(object sender, global::System.EventArgs e)
{
if (this.CurrentScheduledTasksDocData != null && this.CurrentScheduledTasksDocData.Store != null)
{
System.Collections.Generic.List<DslModeling::ModelElement> elementList = new System.Collections.Generic.List<Microsoft.VisualStudio.Modeling.ModelElement>();
DslModeling::DepthFirstElementWalker elementWalker = new DslModeling::DepthFirstElementWalker(new ValidateCommandVisitor(elementList), new DslModeling::EmbeddingVisitorFilter(), true);
foreach (object selectedObject in this.CurrentSelection)
{
// Build list of elements embedded beneath the selected root.
DslModeling::ModelElement element = GetValidationTarget(selectedObject);
if (element != null && !elementList.Contains(element))
{
elementWalker.DoTraverse(element);
}
}
this.CurrentScheduledTasksDocData.ValidationController.Validate(elementList, DslValidation::ValidationCategories.Menu);
}
}
示例15: DropColumns
public static Matrix DropColumns(Matrix mat, params int[] columns)
{
System.Collections.Generic.List<int> li = new System.Collections.Generic.List<int>(columns);
Matrix m = new Matrix(mat.Height, mat.Width - li.Count);
for (int jj = 0, j = 0; j < mat.Width; j++)
{
if (li.Contains(j))
continue;
for (int i = 0; i < mat.Height; i++)
{
m[i, jj] = mat[i, j];
}
jj++;
}
return m;
}