public FlexibleWordCountModel(ISingleWordCountModel countsWithQuotes, ISingleWordCountModel countsWithoutQuotes) { if (countsWithQuotes == countsWithoutQuotes) { throw new ArgumentException("Please supply two different count models."); } if (countsWithQuotes == null || countsWithoutQuotes == null) { throw new ArgumentException("Array of counts must not be null."); } int withQuotesLength = countsWithQuotes.GetLength(); int withoutQuotesLength = countsWithoutQuotes.GetLength(); if (withQuotesLength < 1 || withoutQuotesLength < 1) { throw new ArgumentException("The count collections must not have length zero."); } if (withQuotesLength != withoutQuotesLength) { throw new ArgumentException($"The count collections must have the same length."); } for (int i = 0; i < withQuotesLength; i++) { if (countsWithQuotes.GetAt(i) < 0 || countsWithoutQuotes.GetAt(i) < 0) { throw new ArgumentException($"Counts must not be negative. Item {i} in one of the arrays was negative."); } } _length = withQuotesLength; _countsWithQuotes = countsWithQuotes.Copy(); _countsWithoutQuotes = countsWithoutQuotes.Copy(); }
public ISingleWordCountModel GetCounts() { if (_modified) { CalculateFingerprint(); _modified = false; } return(_counts.Copy()); }
public void TestCopy() { ISingleWordCountModel copy = singleWordCountModel.Copy(); Assert.AreEqual(copy.GetAt(0), singleWordCountModel.GetAt(0)); Assert.AreEqual(copy.GetAt(1), singleWordCountModel.GetAt(1)); Assert.AreEqual(copy.GetAt(2), singleWordCountModel.GetAt(2)); Assert.AreEqual(copy.GetAt(3), singleWordCountModel.GetAt(3)); Assert.AreEqual(copy.GetAt(4), singleWordCountModel.GetAt(4)); }
public GroupModel(string name, ISingleWordCountModel wordCountModel) { SetName(name); if (wordCountModel == null) { throw new ArgumentException("wordCountModel must not be null."); } for (int i = 0; i < wordCountModel.GetLength(); i++) { if (wordCountModel.GetAt(i) != 0) { throw new ArgumentException("wordCountModel must have counts all equal to zero upon initializing group."); } } _items = new List <ITextOrGroupModel>(); _counts = wordCountModel.Copy(); _length = _counts.GetLength(); _modified = true; }
public ISingleWordCountModel CountsWithoutQuotes() { return(_countsWithoutQuotes.Copy()); }