public bool Remove(SingleByteString sbs) { bool result = sbs.Segment.Remove(sbs.Start); if (result) { Count--; } return(result); }
internal SingleByteString Add(string s, int length) { var result = new SingleByteString(this, _nextStart); int newStart = _nextStart + HeaderLength + length; if (_data.Length < newStart) { Array.Resize(ref _data, newStart + _options.GrowthIncrement); } // Write header WriteHeader(ref _nextStart, length); // Write payload _options.Encoding.GetBytes(s, 0, length, _data, _nextStart); _nextStart = newStart; return(result); }
public SingleByteString Add(string s) { SingleByteString result; int length = s.Length; if (length > SingleByteStringStorageSegment.MaxStringLength) { throw new ArgumentException($"{nameof(SingleByteStringStorage)} cannot hold individual strings longer than {SingleByteStringStorageSegment.MaxStringLength}."); } else if (length == 0) { result = new SingleByteString(); } else { if (!_currentSegment.CanHold(length)) { CreateNewCurrentSegment(); } result = _currentSegment.Add(s, length); Count++; } return(result); }