public void Set(IntArrow <TAttr> newArrow) { #if false if (newArrow.Value.Equals(DefaultValue)) { Clear(newArrow.Key); return; } #endif IntInterval bounds = newArrow.Key; var relation = ParseBoundsRelation(bounds); if (relation.ContainsIndex >= 0) { int i = relation.ContainsIndex; var oldArrow = arrows[i]; if (oldArrow.Value.Equals(newArrow.Value)) { return; } var before = oldArrow.Before(bounds); if (!before.IsEmpty) { arrows.Insert(i, before); ++i; } arrows[i] = newArrow; ++i; var after = oldArrow.After(bounds); if (!after.IsEmpty) { arrows.Insert(i, after); } return; } if (relation.FirstOverlapIndex >= 0) { int i = relation.FirstOverlapIndex; arrows[i] = arrows[i].Before(bounds); } int shift = 0; Debug.Assert(relation.ReplaceIndex >= 0); arrows.Insert(relation.ReplaceIndex, newArrow); ++shift; foreach (int containedIndex in relation.ContainedIndexes) { arrows.RemoveAt(containedIndex + shift); --shift; } if (relation.LastOverlapIndex >= 0) { arrows[relation.LastOverlapIndex + shift] = arrows[relation.LastOverlapIndex + shift].After(bounds); } }
public UniformIntFrequency(IntInterval bounds) { double elementProbability = bounds.IsEmpty ? 0 : (1.0 / bounds.LongSize); this.arrow = new IntArrow <double>(bounds, elementProbability); }