using System; using System.Collections.Generic; namespace Lextm.SharpSnmpLib.Mib { public class ValueMap : Dictionary { public ValueMap() { } /// /// Returns the values of the map as continous range. At best as one range. /// /// public ValueRanges GetContinousRanges() { ValueRanges result = new ValueRanges(); if (this.Count > 0) { List values = new List(this.Keys); values.Sort(); Int64 last = values[0]; Int64 offset = values[0]; for (int i=1; i /// Gets the highest value contained in this value map. /// /// public Int64 GetHighestValue() { Int64 result = 0; foreach (Int64 value in this.Keys) { if (value > result) { result = value; } } return result; } /// /// Interprets the single values as bit positions and creates a mask of it. /// /// public UInt32 GetBitMask() { UInt32 result = 0; foreach (Int64 key in this.Keys) { if (key < 0) { throw new NotSupportedException("Negative numbers are not allowed for Bits!"); } if (key > 31) { throw new NotSupportedException("Bits with more than 32 bits are not supported!"); } result |= (UInt32)(1 << (int)key); } return result; } } }