public VersionDictionary(string name) { _syncRoot = (_innerList is ICollection) ? (((ICollection)_innerList).SyncRoot ?? new object()) : new object(); _name = name; _keys = new KeyCollection <AssemblyEntry, Version, Assembly>(_innerList, a => (a == null) ? null : a.Name.Version, a => (a == null) ? null : a.Assembly); _values = new ValueCollection <AssemblyEntry, Assembly>(_innerList, a => (a == null) ? null : a.Assembly); }
private void SetKnownHeader(int knownHeaderValue, ValueCollection valueCollection) { if (knownHeaderValue < 0 || knownHeaderValue > KnownHeadersCapacity) { throw new ArgumentOutOfRangeException(nameof(knownHeaderValue)); } if (this.knownHeaders == null) { this.knownHeaders = new ValueCollection[KnownHeadersCapacity]; } var oldValue = this.knownHeaders[knownHeaderValue]; this.knownHeaders[knownHeaderValue] = valueCollection; if (oldValue.IsEmpty && !valueCollection.IsEmpty) { this.knownHeadersCount++; } else if (!oldValue.IsEmpty && valueCollection.IsEmpty) { this.knownHeadersCount--; } this.version++; }
/// <summary> /// Converts a ValueCollection to a generic list of objects /// </summary> /// <param name="values">The value collection object</param> /// <returns>A generic list of objects</returns> public static IList <object> ToList(this ValueCollection values) { List <object> list = new List <object>(); foreach (Value value in values.OfType <Value>()) { switch (value.DataType) { case AttributeType.Binary: list.Add(value.ToBinary()); break; case AttributeType.Boolean: list.Add(value.ToBoolean()); break; case AttributeType.Integer: list.Add(value.ToInteger()); break; case AttributeType.String: case AttributeType.Reference: list.Add(value.ToString()); break; case AttributeType.Undefined: default: throw new UnknownOrUnsupportedDataTypeException(); } } return(list); }
/// <summary> /// 将 <see cref="GenericDictionary{TKey, TValue}"/> 类的新实例初始化为指定字典的包装。 /// </summary> /// <param name="dictionary">要包装的字典。</param> /// <exception cref="ArgumentNullException"> /// <paramref name="dictionary"/> 为 <see langword="null"/>。</exception> public GenericDictionary(IDictionary dictionary) { this.Dictionary = dictionary ?? throw new ArgumentNullException(nameof(dictionary)); this.GenericKeys = new KeyCollection(this.Dictionary); this.GenericValues = new ValueCollection(this.Dictionary); }
public WeakKeyDictionary(int capacity, IEqualityComparer <TKey> comparer) { _comparer = new WeakKeyComparer <TKey>(comparer); _dict = new Dictionary <object, TValue>(capacity, _comparer); _keyColl = new KeyCollection(this); _valueColl = new ValueCollection(this); }
private void plugin_OnRemovedFromManager(Plugin sender, PluginManager manager) { Event.Callback <Plugin, PluginManager> callback; int i; Func <Command.ChatCommand, bool> func = null; Command.ConsoleCommand[] array = ( from c in this.consoleCommands.Values where c.Callback.Plugin == sender select c).ToArray <Command.ConsoleCommand>(); for (i = 0; i < (int)array.Length; i++) { this.RemoveConsoleCommand(array[i]); } Dictionary <!0, !1> .ValueCollection values = this.chatCommands.Values; Func <Command.ChatCommand, bool> func1 = func; if (func1 == null) { Func <Command.ChatCommand, bool> plugin = (Command.ChatCommand c) => c.Plugin == sender; Func <Command.ChatCommand, bool> func2 = plugin; func = plugin; func1 = func2; } Command.ChatCommand[] chatCommandArray = values.Where <Command.ChatCommand>(func1).ToArray <Command.ChatCommand>(); for (i = 0; i < (int)chatCommandArray.Length; i++) { this.RemoveChatCommand(chatCommandArray[i]); } if (this.pluginRemovedFromManager.TryGetValue(sender, out callback)) { callback.Remove(); this.pluginRemovedFromManager.Remove(sender); } }
public OrderedDictionaryG(IEqualityComparer <TKey> comparer) { mDictionary = new Dictionary <TKey, LinkedListNode <KeyValuePair <TKey, TValue> > >(comparer); mLinkedList = new LinkedList <KeyValuePair <TKey, TValue> >(); valueCollection = new ValueCollection(this); keyCollection = new KeyCollection(this); }
/// <summary> /// Gets or sets the list of values associated with the specified key. /// Returns an empty list if there are none. /// </summary> /// <param name="key">The key.</param> /// <returns>The list of values.</returns> public IList <TValue> this[TKey key] { get { IList <TValue> list; if (entries.TryGetValue(key, out list)) { return(list); } return(EmptyArray <TValue> .Instance); } set { if (value == null) { throw new ArgumentNullException(@"value"); } if (value.Count != 0) { entries[key] = new ValueCollection(value); } else { entries.Remove(key); } } }
public void SimpleEncodingDataGetsEncoded() { var chart = GetLineChartForTesting(); chart.Encoding = Encoding.SimpleEncoding; var values = new ValueCollection(); for (var i = 0; i < 63; i++) { values.Add(new ValueInformation() { Value = i }); } chart.DataSets = new DataSetCollection() { new ChartDataSet() { Values = values } }; var expectedValue = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; var url = chart.GetURL(); Assert.IsTrue(url.Contains(GetTestableValue(expectedValue))); }
public OrderedDictionaryG(int capacity) { mDictionary = new Dictionary <TKey, LinkedListNode <KeyValuePair <TKey, TValue> > >(capacity); mLinkedList = new LinkedList <KeyValuePair <TKey, TValue> >(); valueCollection = new ValueCollection(this); keyCollection = new KeyCollection(this); }
public void CopyTo <TKey, TValue>(ValueCollection <TKey, TValue> collection, TValue[] array, int index) { if (array == null) { throw XExceptions.Argument.IsNull(nameof(array)); } if (index < 0 || index > array.Length) { throw XExceptions.Argument.NonNegativeNumberRequired(); } if (array.Length - index < collection.Dictionary.Count) { throw XExceptions.Argument.ArrayPlusOffTooSmall(); } int count = collection.Dictionary.Count; var entries = collection.Dictionary.Entries; for (int i = 0; i < count; i++) { if (entries[i].HashCode >= 0) { array[index++] = entries[i].Value; } } }
/// <summary> /// Returns a <see cref="System.String"/> that represents this instance. /// </summary> /// <returns> /// A <see cref="System.String"/> that represents this instance. /// </returns> public override string ToString() { var sb = new StringBuilder(); // Base operator sb.Append("CALL "); sb.Append(Procedure); sb.Append("("); // Columns var values = ValueCollection.GetValues(); if (values != null && values.Length > 0) { foreach (var v in values) { sb.Append(v); sb.Append(","); } sb.Length--; } sb.Append(")"); return(sb.ToString()); }
private void CheckParams(string[] args, ref ValueCollection collection) { for (int i = 0; i < args.Length; i++) { if (i >= Params.Count) { break; } var arg = args[i]; var param = Params[i]; if (param.Greedy) { collection.Add(param.Name, new ParamValue { Value = string.Join(" ", args, i, args.Length - i) }); break; } object value; bool result = CheckAndConvert(arg, param.Type, out value); collection.Add(param.Name, new ParamValue { Value = value, IsInvalid = !result }); } }
// TODO: merge this function with same function from Source.cs protected List <object> FromValueCollection(object value) { List <object> values = new List <object>(); if (value.GetType() == typeof(List <object>)) { Tracer.TraceInformation("already-type-list"); values = (List <object>)value; } else { Tracer.TraceInformation("transform-converting-to-list"); if (value.GetType() == typeof(System.String)) { values.Add(value); return(values); } ValueCollection vc = (ValueCollection)value; foreach (Microsoft.MetadirectoryServices.Value val in vc) { values.Add(val.ToString()); } } return(values); }
public void AddRange(IEnumerable <Double> values) { foreach (Double value in values) { if (_sequence.Count <= 0) { _sequence.AddLast(new ValueCollection { Value = value, Count = 1, }); ++_count; continue; } ValueCollection collection = _sequence.Last.Value; if (IsClose(collection.Value, value)) { ++collection.Count; } else { collection = new ValueCollection { Value = value, Count = 1, }; _sequence.AddLast(collection); } ++_count; } }
void IMASynchronization.MapAttributesForJoin( string FlowRuleName, CSEntry csentry, ref ValueCollection values) { throw new EntryPointNotImplementedException(); }
public override void Add(ValueCollection val) { foreach (Value item in val) { this.values.Add(item); } }
public void MapAttributesForJoin(string FlowRuleName, CSEntry csentry, ref ValueCollection values) { AttributeType type; IList <object> sourceValues = this.GetSourceValuesForImport(csentry, out type); IList <object> returnValues = Transform.ExecuteTransformChain(this.Transforms, sourceValues); foreach (object value in returnValues) { switch (type) { case AttributeType.Binary: values.Add(TypeConverter.ConvertData <byte[]>(value)); break; case AttributeType.Integer: values.Add(TypeConverter.ConvertData <long>(value)); break; case AttributeType.String: values.Add(TypeConverter.ConvertData <string>(value)); break; case AttributeType.Reference: case AttributeType.Boolean: case AttributeType.Undefined: throw new UnknownOrUnsupportedDataTypeException(); } } }
private void init(IComparer <TKey> comparer) { var keyComparer = new KeyValuePairComparer <TKey, TValue>(comparer); _tree = new RedBlackTree <TKey, TValue>(keyComparer, false); _values = new ValueCollection(_tree); _keys = new KeyCollection(_tree); }
/// <summary> /// Create a new <see cref="Dictionary"/> instance. /// </summary> /// <param name="ARef">The <see cref="Unsafe.AVDictionary"/>.</param> /// <param name="AFlags">The <see cref="AVDictFlags"/>.</param> internal Dictionary(Ref <Unsafe.AVDictionary> ARef, AVDictFlags AFlags) { Ref = ARef; Flags = AFlags; Keys = new KeyCollection(this); Values = new ValueCollection(this); }
public AvlDictionary(IComparer <TK> comparer) { comparer ??= Comparer <TK> .Default; Comparer = comparer; _avl = new AvlTree <KeyValuePair <TK, TV> >(new KeyValuePairComparer(comparer)); Keys = new KeyCollection(this); Values = new ValueCollection(this); }
/// <summary> /// Creates an empty observable dictionary /// </summary> public MtObservableSortedDictionary(IComparer <TK> keyCompare = null) { _keyComparer = keyCompare ?? Comparer <TK> .Default; _backing = new List <KeyValuePair <TK, TV> >(); _keyCollection = new KeysCollection(this); _valueCollection = new ValueCollection(this); Lock = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion); }
public OrderedDictionary(int capacity, IEqualityComparer <TKey>?comparer) { _innerDictionary = new Dictionary <TKey, TValue>(capacity, comparer); _orderedKeys = new LinkedList <TKey>(); _keyCollection = new KeyCollection(_orderedKeys, _innerDictionary); _valueCollection = new ValueCollection(_orderedKeys, _innerDictionary); }
internal static ValueCollection <T> AddFluently <T>(this ValueCollection <T> list, params T[] elements) { foreach (var element in elements) { list.Add(element); } return(list); }
public MySortedList(int capacity) { keys = new List <TKey>(capacity); values = new List <TValue>(capacity); this.keyCollection = new KeyCollection(keys); this.valueCollection = new ValueCollection(values); }
public AVLTreeDictionary() { _root = null; Count = 0; Keys = new KeyCollection(this); Values = new ValueCollection(this); }
public void Can_Construct_Empty_ValueCollection_With_Default_EqualityComparer() { // Act var actual = new ValueCollection <string>(); // Assert actual.Should().BeEmpty(); }
public void Can_Construct_Prefilled_ValueCollection_With_Default_EqualityComparer() { // Act var actual = new ValueCollection <string>(new[] { "a", "b", "c" }); // Assert actual.Should().BeEquivalentTo(new[] { "a", "b", "c" }); }
public ConcurrentBTreeDictionary(IComparer <TKey> cmp) { this.Comparer = cmp ?? throw new ArgumentNullException(nameof(cmp)); this.version = 0; this.InternalNodeChildren = 16; this.LeafNodeChildren = InternalNodeChildren - 1; this.keyCollection = new KeyCollection(this); this.valueCollection = new ValueCollection(this); }
public ObservableDictionary() { _helper = new BlockHelper(); _version = 1; _entrys = new Entry[4]; _keyEquals = EqualityComparer <TKey> .Default; _keys = new KeyCollection(this); _values = new ValueCollection(this); }
/// <summary> /// The MapAttributesForJoin method generates a list of values based on the CSEntry attribute values that will be used to search the metaverse. /// </summary> /// <param name="FlowRuleName">Contains the name of the flow rule. You must use only alphanumeric characters for the FlowRuleName parameter, otherwise you can encounter problems in a rules extension.</param> /// <param name="csentry">Contains a CSEntry object that represents the connector space entry.</param> /// <param name="values">Contains a ValueCollection object that receives the list of attribute values generated by this method to be used to search the metaverse.</param> void IMASynchronization.MapAttributesForJoin(string FlowRuleName, CSEntry csentry, ref ValueCollection values) { throw new EntryPointNotImplementedException(); }