public static TImpl Create(IReadOnlySeries <TKey, TValue> innerSeries) { if (Pool == null || !Pool.TryTake(out TImpl instance)) { instance = new TImpl(); instance._comparer = KeyComparer <TKey2> .Create(new ConvertComparer(instance)); } instance.Inner = innerSeries; return(instance); }
protected AppendSeries(Mutability mutability = Mutability.ReadOnly, KeySorting keySorting = KeySorting.Strong, KeyComparer <TKey> comparer = default, MovingWindowOptions <TKey>?movingWindowOptions = default) : base(mutability, keySorting, comparer) { if (movingWindowOptions != null) { WindowOptions = new MovingWindowOptions(this, movingWindowOptions); } }
// There is no ctors for series because they are read-only, // only factories in static Series class internal Series(Mutability mutability = Mutability.ReadOnly, KeySorting keySorting = KeySorting.Strong, KeyComparer <TKey> comparer = default) { if (keySorting != KeySorting.Strong) { throw new NotImplementedException(); } Flags = new Flags(ContainerLayout.Series, keySorting, mutability); _comparer = comparer; }
public bool Equals(KeyComparer <T> other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(Equals(_comparer, other._comparer) && Equals(_keyComparer, other._keyComparer)); }
internal Range(TCursor cursor, Opt <TKey> startKey, Opt <TKey> endKey, bool startInclusive = true, bool endInclusive = true, bool isWindow = false, int count = -1) : this() { if (!isWindow && cursor.IsIndexed) { ThrowHelper.ThrowNotSupportedException("RangeSeries is not supported for indexed series, only for sorted ones."); } _cmp = cursor.Comparer; if (isWindow && (startKey.IsMissing || endKey.IsMissing || !startInclusive || !endInclusive || _cmp.Compare(cursor.CurrentKey, startKey.Present) != 0)) { ThrowHelper.ThrowInvalidOperationException("Wrong constructor arguments for cursorIsClonedAtStart == true case"); } _cursor = cursor; _isWindow = isWindow; if (startKey.IsPresent) { _flags |= Flags.StartKeyIsPresent; _startKey = startKey.Present; } if (endKey.IsPresent) { _flags |= Flags.EndKeyIsPresent; _endKey = endKey.Present; } if (startInclusive) { _flags |= Flags.StartInclusive; } if (endInclusive) { _flags |= Flags.EndInclusive; } _count = count; }
/// <summary> /// Return a smaller Opt value or Missing if both are missing. Missing value is treated as larger than a present value. /// </summary> public static Opt <T> SmallerOrMissing(Opt <T> first, Opt <T> second, KeyComparer <T> comparer) { if (first.IsMissing && second.IsMissing) { return(Missing); } if (first.IsMissing) { return(second); } if (second.IsMissing) { return(first); } var c = comparer.Compare(first.Value, second.Value); return(c <= 0 ? first : second); }
// There is no ctors for series because they are read-only, // only factories in static Series class internal Series(Mutability mutability = Mutability.ReadOnly, KeySorting keySorting = KeySorting.Strong, KeyComparer <TKey> comparer = default) { // Need to touch these fields very early in a common not hot place for JIT static // readonly optimization even if tiered compilation is off. // Note single & to avoid short circuit. if (AdditionalCorrectnessChecks.Enabled & TypeHelper <TKey> .IsReferenceOrContainsReferences & TypeHelper <TValue> .IsReferenceOrContainsReferences) { ThrowHelper.Assert(!PrivateMemory <TKey> .ObjectPool.IsDisposed); ThrowHelper.Assert(!PrivateMemory <TValue> .ObjectPool.IsDisposed); } if (keySorting != KeySorting.Strong) { throw new NotImplementedException(); } Flags = new Flags(ContainerLayout.Series, keySorting, mutability); _comparer = comparer; }
/// <summary> /// Create a KVP comparer that only compares keys. /// </summary> public KVPComparer(KeyComparer <TKey> keyComparer) { _keyComparer = keyComparer ?? KeyComparer <TKey> .Default; }
/// <summary> /// Create a KVP comparer that only compares keys. Pass null as a second constructor argument /// to use a default comparer for values. With this constructor values are ignored. /// </summary> public KVPComparer(KeyComparer <TKey> keyComparer) { _keyComparer = keyComparer.Equals(default(KeyComparer <TKey>)) ? KeyComparer <TKey> .Default : keyComparer; }
/// <summary> /// Create a KVP comparer that compares keys and values. /// </summary> public KVPComparer(KeyComparer <TKey> keyComparer, KeyComparer <TValue> valueComparer) { _keyComparer = keyComparer.Equals(default(KeyComparer <TKey>)) ? KeyComparer <TKey> .Default : keyComparer; _valueComparer = valueComparer.Equals(default(KeyComparer <TValue>)) ? KeyComparer <TValue> .Default : valueComparer; }
public AppendSeries(KeyComparer <TKey> comparer, KeySorting keySorting, MovingWindowOptions <TKey> movingWindowOptions) : this(Mutability.AppendOnly, keySorting, comparer, movingWindowOptions) { }
protected ConvertSeries(IReadOnlySeries <TKey, TValue> inner) { Inner = inner; _comparer = KeyComparer <TKey2> .Create(new ConvertComparer(this as TImpl)); }
public MutableSeries(KeyComparer <TKey> comparer) : base(Mutability.Mutable, KeySorting.Strong, comparer) { }
public VariantComparer(IReadOnlySeries <TKey, TValue> inner) { _sourceComparer = inner.Comparer; }
public AppendSeries(KeyComparer <TKey> comparer, KeySorting keySorting) : this(Mutability.AppendOnly, keySorting, comparer, default) { }
/// <summary> /// Create a KVP comparer that compares keys and values. /// </summary> public KVPComparer(KeyComparer <TKey> keyComparer, KeyComparer <TValue> valueComparer) { _keyComparer = keyComparer ?? KeyComparer <TKey> .Default; _valueComparer = valueComparer ?? KeyComparer <TValue> .Default; }
public MutableSeries(KeyComparer <TKey> comparer, KeySorting keySorting) : base(Mutability.Mutable, keySorting, comparer, default) { }
public MutableSeries(KeyComparer <TKey> comparer, KeySorting keySorting, MovingWindowOptions <TKey> movingWindowOptions) : base(Mutability.Mutable, keySorting, comparer, movingWindowOptions) { }
public VariantSeries(IReadOnlySeries <TKey, TValue> inner) { Inner = inner; _comparer = KeyComparer <Variant> .Create(new VariantComparer(Inner)); }
public AppendSeries(KeyComparer <TKey> comparer) : this(Mutability.AppendOnly, KeySorting.Strong, comparer) { }