public IList <NIFObject> getObjects() { if (objCache == null) { objCache = new C5.ArrayList <NIFObject>(objects.Count); objCache.AddAll(objects.Values); } return(objCache); }
public static IEnumerable <IPathNode <N> > GetReachableNodes <N>(N start, float maxCost) where N : INode <N> { C5.IDictionary <N, PathNode <N> > nodeDictionary = new C5.HashDictionary <N, PathNode <N> >(); C5.IPriorityQueue <PathNode <N> > openSet = new C5.IntervalHeap <PathNode <N> >(new PathNodeComparer <N>(), C5.MemoryType.Normal); C5.ICollection <N> closedSet = new C5.HashSet <N>(); C5.ArrayList <IPathNode <N> > res = new C5.ArrayList <IPathNode <N> >(C5.MemoryType.Normal); PathNode <N> curNode = new PathNode <N>(start); curNode.g = 0; nodeDictionary.Add(start, curNode); while (true) { res.Add(curNode); foreach (IEdge <N> edge in curNode.node) { N other = edge.GetEnd(); if (!closedSet.Contains(other)) { PathNode <N> otherNode = null; if (!nodeDictionary.Find(ref other, out otherNode)) { otherNode = new PathNode <N>(other); nodeDictionary.Add(other, otherNode); } float newG = edge.GetCost() + curNode.g; if (otherNode.g > newG) { otherNode.g = newG; if (otherNode.queueHandle != null) { openSet.Replace(otherNode.queueHandle, otherNode); } otherNode.prev = curNode; } if (otherNode.queueHandle == null) { C5.IPriorityQueueHandle <PathNode <N> > handle = null; openSet.Add(ref handle, otherNode); otherNode.queueHandle = handle; } } } if (openSet.IsEmpty) { return(res); } closedSet.Add(curNode.node); curNode = openSet.DeleteMin(); if (curNode.g > maxCost) { return(res); } } }
private void SetupChildrenCollection() { var children = new C5.ArrayList <RouteHandler> (); children.ItemInserted += HandleChildrenCollectionChanged; children.ItemsAdded += HandleChildrenCollectionChanged; children.ItemRemovedAt += HandleChildrenCollectionChanged; children.ItemsRemoved += HandleChildrenCollectionChanged; Children = children; }
private void scrobbleOnThisDate_Click(object sender, EventArgs e) { if (files.Length > 50) { MessageBox.Show("Scrobbling more than 50 tracks - last.fm response may be lagged.", "Tracks, a lot!", MessageBoxButtons.OK, MessageBoxIcon.Information); } C5.ArrayList <TrackInfo> tracks = new C5.ArrayList <TrackInfo>(); try { foreach (object file in this.files) { UltraListViewItem item = (UltraListViewItem)file; TrackInfo info = new TrackInfo(item.SubItems[1].Value.ToString(), item.SubItems[2].Value.ToString(), item.SubItems[0].Value.ToString()); //artist (!empty), album (may be empty), title (!empty) info.Username = this.username; info.Duration = (int)TimeSpan.Parse(item.SubItems[3].Value.ToString()).TotalSeconds; info.SourceString = "P"; info.SetTimeStamp((long)UnixTime.GetUnixTimeOfDate(rTime).TotalSeconds); rTime = rTime.AddSeconds(info.Duration + 10 * ((new Random()).NextDouble())); for (int i = 0; i < (int)item.SubItems[4].Value; i++) { tracks.Add(info); } } //for (int j = 0; j < files.Length; j++) //{ tracks.Shuffle(); //} ScrobblerCache cache = new ScrobblerCache(this.username); cache.Append(new List <TrackInfo>(tracks.ToArray()), true); sm.Scrobble(ref cache); if (MessageBox.Show("Scrobbled successfully! Close date scrobble dialog? ", "Oll Korrect", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { this.Close(); } } catch (Exception exp) { MessageBox.Show(exp.Message, "Something happened!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
internal void FrustumCull(ref Part[] parts, ref C5.ArrayList <Part> output) { var ghost = _frustumGhost; var numOverlap = ghost.NumOverlappingObjects; for (int i = 0; i < numOverlap; i++) { var obj = ghost.GetOverlappingObject(i); var part = obj.UserObject as Part; if (part != null) { output.Add(part); } } }
private static string ReferenceRandomizer(string s) { if (string.IsNullOrEmpty(s)) { return(s); } // use C5 shuffle to start var chars = new C5.ArrayList <char>(s.Length); chars.AddAll(s.ToCharArray()); chars.Shuffle(); return(new string(chars.ToArray())); }
private static void RunNumbers() { _People = new C5.ArrayList<Person>(); //_Ages = new List<int>(); //_ReproStarts = new List<int>(); //_ReproEnds = new List<int>(); //var stp = new Stopwatch(); //stp.Start(); for (int i = 0; i < _InitialPopulationMale; i++) { _People.Add(new Person(0, false, false, true)); } for (int i = 0; i < _InitialPopulationFemale; i++) { _People.Add(new Person(0, true, true, true)); } for (int i = 0; i < _EndYear; i++) { _CurrentYear = i; //Console.Write("."); //Console.WriteLine("Year {0}", i); _People.RemoveAll(_People.Where(y => !y.IsAlive)); Console.WriteLine("Year {0}: {1} People", i, _People.Count().ToString("#,##0")); long newPeeps = _People.Count(x => x.IsMakinABaby); newPeeps = (long)(newPeeps * 1.04); // account for twins, triplets, etc based upon estimate from http://www.cdc.gov/nchs/fastats/multiple.htm (33.1 twins per 1000, 3x or higeher 124.4/100,000) _People.AddAll(Enumerable.Range(1, newPeeps).Select(x => new Person(i, null, null, false))); } //Console.WriteLine("Year {0}: {1} People, Avg age: {2}, Avg Repro Start: {3}, Avg Repro End: {4}", _EndYear, _People.Count(x => x.IsAlive).ToString("#,##0"), _Ages.Average(), _ReproStarts.Average(), _ReproEnds.Average()); Console.WriteLine("Year {0}: {1} People", _EndYear, _People.Count().ToString("#,##0")); Console.WriteLine("-----"); Console.WriteLine("DONE"); Console.WriteLine("-----"); Console.WriteLine("What now? ([R]epeat, [S]tart over, [Q]uit"); Console.Beep(); var action = Console.ReadLine(); if (action.ToUpper() == "REPEAT" || action.ToUpper() == "R") { RunNumbers(); } else if (action.ToUpper() == "START OVER" || action.ToUpper() == "S") { InitAndRun(); } else { // quit } }
public void C5_ArrayList() => _ = new C5.ArrayList <Int32>(32);
public override Explanation Explain(int doc) { string[] vals = _array.getTranslatedData(doc, _dataCache.valArray); C5.ArrayList<float> scoreList = new C5.ArrayList<float>(_dataCache.valArray.Count); List<Explanation> explList = new List<Explanation>(scoreList.Count); foreach (string val in vals) { int idx = _dataCache.valArray.IndexOf(val); if (idx >= 0) { scoreList.Add(Function.Score(_dataCache.freqs[idx], BoostList[idx])); explList.Add(Function.Explain(_dataCache.freqs[idx], BoostList[idx])); } } Explanation topLevel = Function.Explain(scoreList.ToArray()); foreach (Explanation sub in explList) { topLevel.AddDetail(sub); } return topLevel; }
private void scrobbleOnThisDate_Click(object sender, EventArgs e) { if (files.Length > 50) { MessageBox.Show("Scrobbling more than 50 tracks - last.fm response may be lagged.", "Tracks, a lot!", MessageBoxButtons.OK, MessageBoxIcon.Information); } C5.ArrayList<TrackInfo> tracks = new C5.ArrayList<TrackInfo>(); try { foreach (object file in this.files) { UltraListViewItem item = (UltraListViewItem)file; TrackInfo info = new TrackInfo(item.SubItems[1].Value.ToString(), item.SubItems[2].Value.ToString(), item.SubItems[0].Value.ToString()); //artist (!empty), album (may be empty), title (!empty) info.Username = this.username; info.Duration = (int)TimeSpan.Parse(item.SubItems[3].Value.ToString()).TotalSeconds; info.SourceString = "P"; info.SetTimeStamp((long) UnixTime.GetUnixTimeOfDate(rTime).TotalSeconds); rTime = rTime.AddSeconds(info.Duration + 10 * ( (new Random() ).NextDouble() ) ); for (int i = 0; i < (int)item.SubItems[4].Value; i++) tracks.Add(info); } //for (int j = 0; j < files.Length; j++) //{ tracks.Shuffle(); //} ScrobblerCache cache = new ScrobblerCache(this.username); cache.Append(new List<TrackInfo>(tracks.ToArray()), true); sm.Scrobble(ref cache); if (MessageBox.Show("Scrobbled successfully! Close date scrobble dialog? ", "Oll Korrect", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { this.Close(); } } catch(Exception exp) { MessageBox.Show(exp.Message, "Something happened!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public static IEnumerable <IPathNode <N> > GetShortestPath <N>(N start, N goal, IHeuristic <N> heuristic) where N : INode <N> { C5.IDictionary <N, PathNode <N> > nodeDictionary = new C5.HashDictionary <N, PathNode <N> >(); C5.IPriorityQueue <PathNode <N> > openSet = new C5.IntervalHeap <PathNode <N> >(new PathNodeComparer <N>()); C5.ICollection <N> closedSet = new C5.HashSet <N>(); PathNode <N> curNode = new PathNode <N>(start); curNode.g = 0; nodeDictionary.Add(start, curNode); while (true) { foreach (IEdge <N> edge in curNode.Node) { N other = edge.GetEnd(); if (!closedSet.Contains(other)) { PathNode <N> otherNode = null; if (!nodeDictionary.Find(ref other, out otherNode)) { otherNode = new PathNode <N>(other); nodeDictionary.Add(other, otherNode); } float newG = edge.GetCost() + curNode.g; if (otherNode.g > newG) { otherNode.g = newG; if (otherNode.queueHandle != null) { openSet.Replace(otherNode.queueHandle, otherNode); } otherNode.prev = curNode; } if (otherNode.queueHandle == null) { otherNode.h = heuristic.MinDist(other, goal); C5.IPriorityQueueHandle <PathNode <N> > handle = null; openSet.Add(ref handle, otherNode); otherNode.queueHandle = handle; } } } if (openSet.IsEmpty) { return(null); } closedSet.Add(curNode.Node); curNode = openSet.DeleteMin(); if (curNode.Node.Equals(goal)) { C5.ArrayList <IPathNode <N> > res = new C5.ArrayList <IPathNode <N> >(); do { res.Add(curNode); curNode = curNode.prev; } while (curNode != null); res.Reverse(); return(res); } } }