public override void Merge(DocValuesFieldUpdates other) { BinaryDocValuesFieldUpdates otherUpdates = (BinaryDocValuesFieldUpdates)other; int newSize = Size + otherUpdates.Size; if (newSize > int.MaxValue) { throw new InvalidOperationException("cannot support more than Integer.MAX_VALUE doc/value entries; size=" + Size + " other.size=" + otherUpdates.Size); } Docs = Docs.Grow(newSize); Offsets = Offsets.Grow(newSize); Lengths = Lengths.Grow(newSize); DocsWithField = FixedBitSet.EnsureCapacity(DocsWithField, (int)Docs.Size()); for (int i = 0; i < otherUpdates.Size; i++) { int doc = (int)otherUpdates.Docs.Get(i); if (otherUpdates.DocsWithField.Get(i)) { DocsWithField.Set(Size); } Docs.Set(Size, doc); Offsets.Set(Size, Values.Length + otherUpdates.Offsets.Get(i)); // correct relative offset Lengths.Set(Size, otherUpdates.Lengths.Get(i)); ++Size; } Values.Append(otherUpdates.Values); }
protected override void GenerateInner(CodeGenerator generator) { generator.Write(TokenType.Keyword, "new"); generator.Write(TokenType.Space, ' '); if (Lengths.Count > 0) { CreateType.NestedElementType.Generate(generator); generator.Write(TokenType.Punctuation, '['); Lengths.GenerateCommaSeparated(generator); generator.Write(TokenType.Punctuation, ']'); generator.Write(TokenType.Punctuation, CreateType.ArrayElementType.CompleteArraySuffix); } else { CreateType.Generate(generator); } if (Initializer.Count > 0 || Lengths.Count == 0) { generator.Write(TokenType.Punctuation, '{'); Initializer.GenerateCommaSeparated(generator); generator.Write(TokenType.Punctuation, '}'); } }
private void CalculateLengths() { for (int point = 0; point < 3; ++point) { Lengths.Add(Point.GetDistance(Vertices[point], Vertices[(point + 1) % 3])); } }
internal void Expand(OptimizationContext context) { if (!Optimized) { return; } Starts.ExpandData(context); Lengths.ExpandData(context); SharedIndices.ExpandData(context); if (!StartsExpanded) { ExpandStarts(); } ExpandLists(context); if (FullLength == 0) { var end = Starts[Starts.Count - 1] + Lengths[Lengths.Count - 1]; FullLength = end - Starts.MinValue + 1; } Optimized = false; }
public double ChangeLengthUnit(double LengthValue, Lengths fromLengthUnit, Lengths toLengthUnit) { object[] results = this.Invoke("ChangeLengthUnit", new object[] { LengthValue, fromLengthUnit, toLengthUnit }); return((double)(results[0])); }
public CodeArrayCreateExpression(CodeTypeReference type, IEnumerable <CodeExpression> lengths, IEnumerable <CodeExpression> initializer) { Ensure.That(nameof(type)).IsNotNull(type); Ensure.That(nameof(lengths)).IsNotNull(lengths); Ensure.That(nameof(initializer)).IsNotNull(initializer); CreateType = type; Lengths.AddRange(lengths); Initializer.AddRange(initializer); }
/// <remarks/> public void ChangeLengthUnitAsync(double LengthValue, Lengths fromLengthUnit, Lengths toLengthUnit, object userState) { if ((this.ChangeLengthUnitOperationCompleted == null)) { this.ChangeLengthUnitOperationCompleted = new System.Threading.SendOrPostCallback(this.OnChangeLengthUnitOperationCompleted); } this.InvokeAsync("ChangeLengthUnit", new object[] { LengthValue, fromLengthUnit, toLengthUnit }, this.ChangeLengthUnitOperationCompleted, userState); }
public IActionResult Calculate(Lengths length) { if (length.conversion == true) { length.answer = length.from * 12; } else { length.answer = length.from / 12; } return(View(length)); }
public multilingual_unicode_string_list(CacheBase Cache, int Address) { EndianReader Reader = Cache.Reader; Reader.SeekTo(Address); Reader.SeekTo(Address + 32); for (int i = 0; i < 12; i++) { Indices.Add(Reader.ReadUInt16()); Lengths.Add(Reader.ReadUInt16()); } }
public ValidationResult Validate(string value) { // Check if value is missing if (string.IsNullOrEmpty(value)) { return(ValidationResult.ValueMissing); } if (value.Length < 2) { return(ValidationResult.ValueTooSmall); } var countryCode = value.Substring(0, 2).ToUpper(); int lengthForCountryCode; var countryCodeKnown = Lengths.TryGetValue(countryCode, out lengthForCountryCode); if (!countryCodeKnown) { return(ValidationResult.CountryCodeNotKnown); } // Check length. if (value.Length < lengthForCountryCode) { return(ValidationResult.ValueTooSmall); } if (value.Length > lengthForCountryCode) { return(ValidationResult.ValueTooBig); } value = value.ToUpper(); var newIban = value.Substring(4) + value.Substring(0, 4); newIban = Regex.Replace(newIban, @"\D", match => (match.Value[0] - 55).ToString()); var remainder = BigInteger.Parse(newIban) % 97; if (remainder != 1) { return(ValidationResult.ValueFailsModule97Check); } return(ValidationResult.IsValid); }
private void Init() { Lengths.Add(3, 1); Lengths.Add(4, 1); Lengths.Add(5, 2); Lengths.Add(6, 2); Lengths.Add(7, 3); Lengths.Add(8, 3); HasParameters.Add(4); HasParameters.Add(5); HasParameters.Add(6); HasParameters.Add(7); HasParameters.Add(8); }
public string ConvertLength(double value, Lengths from, Lengths to) { try { address = new EndpointAddress("http://www.webservicex.net/length.asmx?WSDL"); lengthUnitSoapClient lusc = new lengthUnitSoapClient(binding, address); double converted_value = lusc.ChangeLengthUnit(value, from, to); return(converted_value.ToString()); } catch (Exception ex) { return("Convertion Error: " + ex.Message); } }
public object Clone() { StrikeWeight strikeWeight = (StrikeWeight)MemberwiseClone(); if (Lengths != null) { strikeWeight.Lengths = new List <Length>(); Lengths.ForEach(le => strikeWeight.Lengths.Add((Length)le.Clone())); } if (DayParts != null) { strikeWeight.DayParts = new List <DayPart>(); DayParts.ForEach(dp => strikeWeight.DayParts.Add((DayPart)dp.Clone())); } return(strikeWeight); }
public IActionResult LengthsConvert(decimal lengthIn) { var mToF = new Lengths(); var fToM = new Lengths(); var mtoY = new Lengths(); var ytoM = new Lengths(); var fToY = new Lengths(); var ytoF = new Lengths(); ViewData["mToF"] = mToF.MetersToFeet(lengthIn); ViewData["fToM"] = fToM.FeetToMeters(lengthIn); ViewData["mtoY"] = mtoY.MetersToYards(lengthIn); ViewData["ytoM"] = ytoM.YardsToMeters(lengthIn); ViewData["fToY"] = fToY.FeetToYards(lengthIn); ViewData["yToF"] = ytoF.YardsToFeet(lengthIn); return(View()); }
internal void Optimize(OptimizationContext context) { if (Optimized) { return; } if (FullLength == 0) { var end = Starts[Starts.Count - 1] + Lengths[Lengths.Count - 1]; FullLength = end - Starts.MinValue + 1; } OptimizeStarts(context); Starts.Optimize(context); Lengths.Optimize(context); SharedIndices.Optimize(context); OptimizeLists(context); Optimized = true; }
public override void Add(int doc, object value) { // TODO: if the Sorter interface changes to take long indexes, we can remove that limitation if (Size == int.MaxValue) { throw new InvalidOperationException("cannot support more than Integer.MAX_VALUE doc/value entries"); } BytesRef val = (BytesRef)value; if (val == null) { val = BinaryDocValuesUpdate.MISSING; } // grow the structures to have room for more elements if (Docs.Size() == Size) { Docs = Docs.Grow(Size + 1); Offsets = Offsets.Grow(Size + 1); Lengths = Lengths.Grow(Size + 1); DocsWithField = FixedBitSet.EnsureCapacity(DocsWithField, (int)Docs.Size()); } if (val != BinaryDocValuesUpdate.MISSING) { // only mark the document as having a value in that field if the value wasn't set to null (MISSING) DocsWithField.Set(Size); } Docs.Set(Size, doc); Offsets.Set(Size, Values.Length); Lengths.Set(Size, val.Length); Values.Append(val); ++Size; }
void InitTree(DataPacket packet) { bool sparse; int total = 0; if (packet.ReadBit()) { // ordered var len = (int)packet.ReadBits(5) + 1; for (var i = 0; i < Entries;) { var cnt = (int)packet.ReadBits(Utils.ilog(Entries - i)); while (--cnt >= 0) { Lengths[i++] = len; } ++len; } total = 0; sparse = false; } else { // unordered sparse = packet.ReadBit(); for (var i = 0; i < Entries; i++) { if (!sparse || packet.ReadBit()) { Lengths[i] = (int)packet.ReadBits(5) + 1; ++total; } else { Lengths[i] = -1; } } } MaxBits = Lengths.Max(); int sortedCount = 0; int[] codewordLengths = null; if (sparse && total >= Entries >> 2) { codewordLengths = new int[Entries]; Array.Copy(Lengths, codewordLengths, Entries); sparse = false; } // compute size of sorted tables if (sparse) { sortedCount = total; } else { sortedCount = 0; } int sortedEntries = sortedCount; int[] values = null; int[] codewords = null; if (!sparse) { codewords = new int[Entries]; } else if (sortedEntries != 0) { codewordLengths = new int[sortedEntries]; codewords = new int[sortedEntries]; values = new int[sortedEntries]; } if (!ComputeCodewords(sparse, sortedEntries, codewords, codewordLengths, len: Lengths, n: Entries, values: values)) { throw new InvalidDataException(); } LTree = Huffman.BuildLinkedList(values ?? Enumerable.Range(0, codewords.Length).ToArray(), codewordLengths ?? Lengths, codewords); }
private void InitTree(DataPacket packet) { bool sparse; var total = 0; if (packet.ReadBit()) { // ordered var len = (int)packet.ReadBits(5) + 1; for (var i = 0; i < Entries;) { var cnt = (int)packet.ReadBits(Utils.ilog(Entries - i)); while (--cnt >= 0) { Lengths[i++] = len; } ++len; } total = 0; sparse = false; } else { // unordered sparse = packet.ReadBit(); for (var i = 0; i < Entries; i++) { if (!sparse || packet.ReadBit()) { Lengths[i] = (int)packet.ReadBits(5) + 1; ++total; } else { // mark the entry as unused Lengths[i] = -1; } } } // figure out the maximum bit size; if all are unused, don't do anything else if ((MaxBits = Lengths.Max()) > -1) { var sortedCount = 0; int[] codewordLengths = null; if (sparse && total >= Entries >> 2) { codewordLengths = new int[Entries]; Array.Copy(Lengths, codewordLengths, Entries); sparse = false; } // compute size of sorted tables if (sparse) { sortedCount = total; } else { sortedCount = 0; } var sortedEntries = sortedCount; int[] values = null; int[] codewords = null; if (!sparse) { codewords = new int[Entries]; } else if (sortedEntries != 0) { codewordLengths = new int[sortedEntries]; codewords = new int[sortedEntries]; values = new int[sortedEntries]; } if (!ComputeCodewords(sparse, sortedEntries, codewords, codewordLengths, len: Lengths, n: Entries, values: values)) { throw new InvalidDataException(); } PrefixList = Huffman.BuildPrefixedLinkedList(values ?? Enumerable.Range(0, codewords.Length).ToArray(), codewordLengths ?? Lengths, codewords, out PrefixBitLength, out PrefixOverflowTree); } }
public bool IsCompatibleWith(ICursorArray that) { return(Lengths.ValueEquals(that.Lengths)); }
private void Init() { Lengths.Add(9, 1); HasParameters.Add(9); }
public override float GetArea() { float p = Lengths.Sum() / 2; return(MathF.Sqrt(p * (p - Lengths[0]) * (p - Lengths[1]) * (p - Lengths[2]))); }
/// <remarks/> public void ChangeLengthUnitAsync(double LengthValue, Lengths fromLengthUnit, Lengths toLengthUnit) { this.ChangeLengthUnitAsync(LengthValue, fromLengthUnit, toLengthUnit, null); }
private void LoadStrategy() { SlideHeaders.Clear(); SourcePrograms.Clear(); Lengths.Clear(); Stations.Clear(); CustomDemos.Clear(); Dayparts.Clear(); Times.Clear(); if (ResourceManager.Instance.MediaListsFile.ExistsLocal()) { var document = new XmlDocument(); document.Load(ResourceManager.Instance.MediaListsFile.LocalPath); XmlNode node = document.SelectSingleNode(String.Format(@"/{0}Strategy", XmlRootPrefix)); if (node != null) { foreach (XmlNode childeNode in node.ChildNodes) { switch (childeNode.Name) { case "SlideHeader": foreach (XmlAttribute attribute in childeNode.Attributes) { switch (attribute.Name) { case "Value": if (!string.IsNullOrEmpty(attribute.Value) && !SlideHeaders.Contains(attribute.Value)) { SlideHeaders.Add(attribute.Value); } break; } } break; case "FlexFlightDatesAllowed": { bool temp; if (Boolean.TryParse(childeNode.InnerText, out temp)) { FlexFlightDatesAllowed = temp; } } break; case "Daypart": var daypart = new Daypart(); foreach (XmlAttribute attribute in childeNode.Attributes) { switch (attribute.Name) { case "Name": daypart.Name = attribute.Value; break; case "Code": daypart.Code = attribute.Value; break; } } if (!string.IsNullOrEmpty(daypart.Name)) { Dayparts.Add(daypart); } break; case "CustomDemo": foreach (XmlAttribute attribute in childeNode.Attributes) { switch (attribute.Name) { case "Value": if (!CustomDemos.Contains(attribute.Value)) { CustomDemos.Add(attribute.Value); } break; } } break; case "Lenght": foreach (XmlAttribute attribute in childeNode.Attributes) { switch (attribute.Name) { case "Value": if (!string.IsNullOrEmpty(attribute.Value) && !SlideHeaders.Contains(attribute.Value)) { Lengths.Add(attribute.Value); } break; } } break; case "Station": var station = new Station(); foreach (XmlAttribute attribute in childeNode.Attributes) { switch (attribute.Name) { case "Name": station.Name = attribute.Value; break; case "Logo": if (!string.IsNullOrEmpty(attribute.Value)) { station.Logo = new Bitmap(new MemoryStream(Convert.FromBase64String(attribute.Value))); } break; } } if (!string.IsNullOrEmpty(station.Name)) { Stations.Add(station); } break; case "Program": var sourceProgram = new SourceProgram(); GetProgramProperties(childeNode, ref sourceProgram); if (!string.IsNullOrEmpty(sourceProgram.Name)) { SourcePrograms.Add(sourceProgram); } break; case "Status": foreach (XmlAttribute attribute in childeNode.Attributes) { switch (attribute.Name) { case "Value": if (!Statuses.Contains(attribute.Value)) { Statuses.Add(attribute.Value); } break; } } break; case "BroadcastMonthTemplate": var monthTemplate = new MediaMonthTemplate(); monthTemplate.Deserialize(childeNode); MonthTemplatesMondayBased.Add(monthTemplate); MonthTemplatesSundayBased.Add(monthTemplate); break; case "DefaultWeeklyScheduleSettings": DefaultWeeklyScheduleSettings.Deserialize(childeNode); break; case "DefaultMonthlyScheduleSettings": DefaultMonthlyScheduleSettings.Deserialize(childeNode); break; case "DefaultSnapshotSettings": DefaultSnapshotSettings.Deserialize(childeNode); break; case "DefaultSnapshotSummarySettings": DefaultSnapshotSummarySettings.Deserialize(childeNode); break; case "DefaultOptionsSettings": DefaultOptionsSettings.Deserialize(childeNode); break; case "DefaultOptionsSummarySettings": DefaultOptionsSummarySettings.Deserialize(childeNode); break; case "DefaultBroadcastCalendarSettings": DefaultBroadcastCalendarSettings.Deserialize(childeNode); break; case "DefaultCustomCalendarSettings": DefaultCustomCalendarSettings.Deserialize(childeNode); break; } } } } if (SourcePrograms.Count > 0) { Times.AddRange(SourcePrograms.Select(x => x.Time).Distinct().ToArray()); Days.AddRange(SourcePrograms.Select(x => x.Day).Distinct().ToArray()); } }
public IActionResult Index() { Lengths lengths = new Lengths(); return(View(lengths)); }
public bool ValidateLength(string nbPart) { return(Lengths.Any(e => e == nbPart.Length)); }