internal int GetIndex(int ID) { IndexedObject cItem = null; while (zCol.ContainsKey(ID)) { if (zCol.TryGetValue(ID, out cItem)) { return(cItem.Index); } } return(-1); }
internal IndexedObject Item(int ID) { IndexedObject cItem = null; while (zCol.ContainsKey(ID)) { if (zCol.TryGetValue(ID, out cItem)) { return(cItem); } } return(null); }
public IndexedObject Take() // Tries to take an object { // with the lowest index while (!IsEmpty) { IndexedObject cItem = null; if (zCol.TryRemove(Next, out cItem)) { return(cItem); } } return(null); }
internal bool Add(int ID, IndexedObject cObj) { if (cObj == null) { return(false); } if (IsAddingCompleted) { return(false); } cObj.ID = ID; cObj.Index = ID; return(zCol.TryAdd(ID, cObj)); }
private static void AssertLogParam(Log expectedLog, IndexedObject expectedLogParam, string xmlOut) { var logList = EnergisticsConverter.XmlToObject <LogList>(xmlOut); Assert.IsNotNull(logList); Assert.IsTrue(logList.Log.Count > 0); var log = logList.Log.FirstOrDefault(x => x.Uid == expectedLog.Uid); Assert.IsNotNull(log); var logParam = log.LogParam.FirstOrDefault(x => x.Name == expectedLogParam.Name); Assert.IsNotNull(logParam); Assert.AreEqual(expectedLogParam.Value, logParam.Value); Assert.AreEqual(expectedLogParam.Uom, logParam.Uom); Assert.AreEqual(expectedLogParam.Description, logParam.Description); Assert.AreEqual(expectedLogParam.Index, logParam.Index); }
public bool Remove(int ID = -1) { if (ID == -1) { Clear(); return(true); } IndexedObject cItem = null; while (!zCol.TryRemove(ID, out cItem)) { if (!zCol.ContainsKey(ID)) { return(false); } } return(true); }
internal List <IndexedObject> ObjectList(int ObjectID = -1) { List <IndexedObject> sList = new List <IndexedObject>(); if (ObjectID == -1) { foreach (IndexedObject cItem in Common.EnumObj(zCol.Values.GetEnumerator())) { sList.Add(cItem); } return(sList); } IndexedObject cObj = Item(ObjectID); if (cObj != null) { sList.Add(cObj); } return(sList); }
public int CompareTo(IndexedObject obj) { return(this.Index.CompareTo(obj.Index)); }
public virtual void SetObject(IndexedObject @object) { this.@object = @object; }
public IndexedObject2(string name, IndexedObject @object) { this.name = name; this.@object = @object; }
/// <summary> /// Adds an object to the dictionary /// </summary> /// <param name="key">key for the object</param> /// <param name="value">object to store</param> public void Add(object key, object value) { _maxIndex++; int newIndex = _maxIndex; IndexedObject io = new IndexedObject(newIndex, key, value); _itemsByKey.Add(io.keyObject, io); _itemsByIndex.Add(io.Index, io); }
internal bool Add(IndexedObject cObj) { return(Add(Interlocked.Increment(ref IdCounter), cObj)); }