public void AsEnumerable() { // Create a new Clump<T> object. Clump <string> fruitClump = new Clump <string> { "apple", "passionfruit", "banana", "mango", "orange", "blueberry", "grape", "strawberry" }; // First call to Where(): // Call Clump's Where() method with a predicate. IEnumerable <string> query1 = fruitClump.Where(fruit => fruit.Contains("o")); Assert.IsTrue(fruitClump.ClumpWhereCalled); fruitClump.ClumpWhereCalled = false; // Second call to Where(): // First call AsEnumerable() to hide Clump's Where() method and thereby // force System.Linq.Enumerable's Where() method to be called. IEnumerable <string> query2 = fruitClump.AsEnumerable().Where(fruit => fruit.Contains("o")); Assert.IsFalse(fruitClump.ClumpWhereCalled); }
static void LinqAsEnumerable() { Console.WriteLine("=== " + MethodInfo.GetCurrentMethod().Name + " ==="); // Create a new Clump<T> object. var fruitClump = new Clump <string> { "apple", "passionfruit", "banana", "mango", "orange", "blueberry", "grape", "strawberry" }; // First call to Where(): // Call Clump's Where() method with a predicate. var query1 = fruitClump.Where(fruit => fruit.Contains("o")); Console.WriteLine("query1 has been created."); foreach (var f in query1) { Console.WriteLine(f); } // Second call to Where(): // First call AsEnumerable() to hide Clump's Where() method and thereby // force System.Linq.Enumerable's Where() method to be called. var query2 = fruitClump.AsEnumerable().Where(fruit => fruit.Contains("o")); // Display the output. Console.WriteLine("query2 has been created."); foreach (var f in query2) { Console.WriteLine(f); } }
public static RWModel ClumpToRWModel(Clump c) { RWModel result = new RWModel(); //only gonna go after the first geometry in clump var geo = c.GeometryList.Geometries[0].Struct; var morphTarget = geo.MorphTargets[0]; result.Verticies = new float[morphTarget.Vertices.Count]; result.Indicies = new int[geo.Triangles.Count]; int j = 0; int a = 0; foreach (var v in morphTarget.Vertices) { result.Verticies[j] = v[0]; result.Verticies[j] = v[1]; result.Verticies[j] = v[2]; j++; } for (int i = 0; i < geo.FaceCount; i++) { result.Indicies[i] = geo.Triangles[a].Vertex3; result.Indicies[i] = geo.Triangles[a].Vertex2; result.Indicies[i] = geo.Triangles[a].Vertex1; } return(result); }
private void AddCellToClump(Clump clump, int sx, int sy, int maxY) { int idx = sx + sy * GridWidth; clump.cells[sx, sy] = grid[idx]; grid[idx] = -1; // check if connected below if (sy < maxY - 1 && grid[sx + (sy + 1) * GridWidth] >= 0) { AddCellToClump(clump, sx, sy + 1, maxY); } // check if connected left if (sx > 0 && grid[(sx - 1) + sy * GridWidth] >= 0) { AddCellToClump(clump, sx - 1, sy, maxY); } // check if connected above if (sy > 0 && grid[sx + (sy - 1) * GridWidth] >= 0) { AddCellToClump(clump, sx, sy - 1, maxY); } // check if connected right if (sx < GridWidth - 1 && grid[(sx + 1) + sy * GridWidth] >= 0) { AddCellToClump(clump, sx + 1, sy, maxY); } }
private Clump GetClump(int sx, int sy) { Clump clump = new Clump(sy + 1); AddCellToClump(clump, sx, sy, sy); return(clump); }
public void makeClump() { pack (); parent = (Clump)GameObject.Instantiate(clump); parent.transform.position = transform.position; parent.speed = stats.speed; transform.SetParent(parent.transform); parent.add(stats); }
void Start() { base.Start(); if(parent){ //pack (); //stats.rigidbody.isKinematic = true; this.transform.parent = parent.transform; this.transform.localPosition = parent.placeNew(); parent.add(this.stats); } }
public override void Load(byte[] data) { if (FileName == "loplyguy.dff") { return; } //throw new Exception("Unreadable for now!"); } Clump = new Clump(); Clump.Read(new BinaryReader(new MemoryStream(data)), null); Model = RWModel.ClumpToRWModel(Clump); }
public GeometryParts(string name, Clump clump, TextureDictionary[] txds) { Name = name; Geometry = clump.GeometryList.Geometry .Select(x => new Geometry(x, Convert(x), txds)) .ToArray(); Frames = clump.FrameList.Frames .Select(x => Convert(x, clump.Atomics)) .ToArray(); _collisions = clump.Collision; }
public void AsEnumerableMethodTest() { Clump <string> fruitClump = new Clump <string> { "apple", "mango", "banana" }; Assert.False(fruitClump.ClumpWhereMethodCalled); fruitClump.Where(x => x.Contains("go")); Assert.True(fruitClump.ClumpWhereMethodCalled); fruitClump.ClumpWhereMethodCalled = false; fruitClump.AsEnumerable().Where(x => x.Contains("go")); Assert.False( fruitClump.ClumpWhereMethodCalled, "IEnumerable<>로 casting. 그래서 Clump:Where는 감춰진다."); }
public void IniciarBuscaRegiaoOri(int tamanhoAglomerado, int tamanhoKMer, int tamanhoRegiaoOri, int distHamming) { Clump algoritmoBusca = new Clump(); SkewDiagram skew = new SkewDiagram(); skew.genoma = arquivoFasta.genoma; skew.tamanhoRegiaoOri = tamanhoRegiaoOri; skew.GerarSkewDiagram(); listSkew = skew.listSkew; ValeSkew = skew.listValesSkew[0]; algoritmoBusca.tamanhoAglomerado = tamanhoAglomerado; algoritmoBusca.tamanhoRegiaoOri = tamanhoRegiaoOri; algoritmoBusca.tamanhoKmer = tamanhoKMer; algoritmoBusca.genoma = arquivoFasta.genoma; algoritmoBusca.listPosBusca = skew.listValesSkew; algoritmoBusca.listRegiaoOri = skew.listRegiaoOri; algoritmoBusca.distanciaHamming = distHamming; algoritmoBusca.inicioRegiaoOriNoGenoma = skew.inicioRegiaoOriNoGenoma; algoritmoBusca.ProcessarGenoma(); Resultado = algoritmoBusca.dadosOri; }
public void removeClump(Clump clump) { clumps--; }
public void addClump(Clump clump) { clumps++; }
private void FallLinesAbove(int startY) { List <Clump> clumps = new List <Clump>(); // find a filled cell for (int y = startY; y >= 0; y--) { for (int x = 0; x < GridWidth; x++) { int idx = x + y * GridWidth; if (grid[idx] >= 0) { Clump clump = GetClump(x, y); clumps.Add(clump); } } } // drop the clumps // first add them all back to the grid since the cells where cleared while collecting clumps for (int i = clumps.Count - 1; i >= 0; i--) { Clump c = clumps[i]; for (int y = 0; y < c.h; y++) { for (int x = 0; x < GridWidth; x++) { grid[x + y * GridWidth] = c.cells[x, y]; } } } // now try to move each clump down a line until none can move bool moved = true; while (moved) { moved = false; foreach (Clump c in clumps) { // remove the cells of this clump from the grid so it don't "collide with itself" for (int y = 0; y < c.h; y++) { for (int x = 0; x < GridWidth; x++) { if (c.cells[x, y] >= 0) { grid[x + (y + c.y) * GridWidth] = -1; } } } // now try to drop the clump down as far possible bool collided = false; while (!collided) { c.y++; // check if any cells will be over another for (int y = 0; y < c.h; y++) { for (int x = 0; x < GridWidth; x++) { if (c.cells[x, y] >= 0) { int idx = x + (y + c.y) * GridWidth; if (idx >= grid.Length || grid[idx] >= 0) { collided = true; break; } } } if (collided) { break; } } if (collided) { c.y--; // revert } else { moved = true; } } // put it back in the grid for (int y = 0; y < c.h; y++) { for (int x = 0; x < GridWidth; x++) { if (c.cells[x, y] >= 0) { grid[x + (y + c.y) * GridWidth] = c.cells[x, y]; } } } } } }
private void CreateClumps() { var graph = new BasicGraph<IntPair>(this.overlapPairs); var connectedComponents = ConnectedComponentCalculator<IntPair>.GetComponents(graph); foreach (var component in connectedComponents) { // GetComponents returns at least one self-entry for each index - including the < FirstNonSentinelOrdinal ones. if (component.Count() == 1) { continue; } var clump = new Clump(component.Select(this.OrdinalToObstacle)); foreach (var obstacle in clump) { obstacle.Clump = clump; } } }