public void Verify_inserts_reverse(string[] items) { var collection = new OrderedCollection <string>(new OrderedCollectionOptions(false, true)); for (var i = 0; i < items.Length; i++) { var item = items[i]; collection.Add(item); Assert.Equal(i + 1, collection.Count); AssertCollection(collection, (x, y) => string.CompareOrdinal(x, y) >= 0); } }
public void Verify_inserts(string[] items) { var collection = new OrderedCollection <string>(); for (int i = 0; i < items.Length; i++) { string item = items[i]; collection.Add(item); Assert.Equal(i + 1, collection.Count); AssertCollection(collection, (x, y) => string.CompareOrdinal(x, y) <= 0); } }
private OrderedCollection <Vertex <T> > GetAdjacent(Vertex <T> v) { if (_adjacent.Contains(v)) { return(_adjacent[v]); } else { OrderedCollection <Vertex <T> > adj = new OrderedCollection <Vertex <T> >(); _adjacent.Add(v, adj); return(adj); } }
public Vertex <T> AddVertex(Vertex <T> v) { if (string.IsNullOrEmpty(v.Name)) { throw new Exception("DirectedGraph.AddVertex(): Vertex name cannot be null."); } if (_vertices.Contains(v.Name)) { throw new Exception("DirectedGraph.AddVertex(): Duplicated vertex: " + v.Name); } _vertices.Add(v.Name, v); return(v); }
public void Should_add_and_enumerate_items() { const int start = 100; const int end = 500; for (var i = start; i < end; i++) { _collection.Add(i); var expected = start; foreach (var v in _collection) { Assert.AreEqual(expected, v); expected++; } Assert.AreEqual(i + 1, expected); for (var j = 0; j < _collection.Count; j++) { Assert.AreEqual(start + j, _collection[j]); } } }
public virtual OrderedCollection <Panel> SerializeChildren(OrderedCollection <BaseWriterPanel> writerPanels) { List <KeyValuePair <string, BaseWriterPanel> > nonNullPanels = new List <KeyValuePair <string, BaseWriterPanel> >(); foreach (var panel in writerPanels) { if (panel.Value != null) { nonNullPanels.Add(panel); } } var panelsArr = new KeyValuePair <string, BaseWriterPanel> [nonNullPanels.Count]; foreach (var panel in nonNullPanels) { var index = panel.Value.transform.GetSiblingIndex(); panelsArr[index] = panel; } var panels = new OrderedCollection <Panel>(); foreach (var writerPanel in panelsArr) { var panel = writerPanel.Value.Serialize(); if (writerPanel.Key == null) { panels.Add(panel); } else { panels.Add(writerPanel.Key, panel); } } return(panels); }
public void LoadFrom(StructuredText node) { _data.Clear(); string classname = typeof(MRUItem).FullName; foreach (StructuredText item in node.Children) { try { //起動高速化のため遅延デシリアライズ if (item.Name == classname) { _data.Add(new MRUItem(item)); } } catch (Exception ex) { RuntimeUtil.ReportException(ex); } } }