TagTool.Cache.TagCache.GetNewTagOffset C# (CSharp) Method

GetNewTagOffset() private method

Gets the offset that a new tag should be inserted at so that the tags are stored in order by index.
private GetNewTagOffset ( int index ) : long
index int The index of the new tag.
return long
        private long GetNewTagOffset(int index)
        {
            if (index < 0)
                throw new ArgumentException("Index cannot be negative");
            if (index >= _tags.Count - 1)
                return GetTagDataEndOffset();
            for (var i = index - 1; i >= 0; i--)
            {
                var tag = _tags[i];
                if (tag != null && tag.HeaderOffset >= 0)
                    return tag.HeaderOffset + tag.TotalSize;
            }
            return CacheHeaderSize;
        }