public void EmptyCharsTest() { var alphabet = new Alphabet(new char[] { }); }
public void ContainsFalseTest() { var alphabet = new Alphabet("ab"); Assert.IsFalse(alphabet.Contains('c')); }
public void ContainsTrueTest() { var alphabet = new Alphabet("ab"); Assert.IsTrue(alphabet.Contains('a')); }
public void NullCharsTest() { var alphabet = new Alphabet(null); }
/// <summary> /// Creates a new alphabet which is a union of two alphabets. /// </summary> /// <param name="a1">The first alphabet.</param> /// <param name="a2">The second alphabet.</param> /// <returns>A new alphabet which is a union of two alphabets.</returns> /// <remarks>This operation is not commutative.</remarks> public static Alphabet Union(Alphabet a1, Alphabet a2) => new Alphabet(a1.indices.Keys.Concat(a2.indices.Keys)) { Name = $"{a1.Name} + {a2.Name}" };
/// <summary> /// Compates the equality of this alphabet to the other alphabet. /// </summary> /// <param name="other">The alphabet to compare to.</param> /// <returns> /// <c>true</c>, if this alphabet equals the other. /// Otherwise, <c>false</c>. /// </returns> public bool Equals(Alphabet other) => other != null && this.indices.Keys.SequenceEqual(other.indices.Keys);