<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CSharpGL
{
    class LineLoopRecognizer : PrimitiveRecognizer
    {
        public override List<RecognizedPrimitiveIndex> Recognize(
            uint lastVertexId, IntPtr pointer, OneIndexBufferPtr oneIndexBufferPtr)
        {
            var lastIndexIdList = new List<RecognizedPrimitiveIndex>();
            int length = oneIndexBufferPtr.Length;
            unsafe
            {
                var array = (uint*)pointer.ToPointer();
                for (uint i = 1; i < length; i++)
                {
                    if (array[i - 0] == lastVertexId)
                    {
                        var item = new RecognizedPrimitiveIndex(lastVertexId, i - 0);
                        item.IndexIdList.Add(array[i - 1]);
                        item.IndexIdList.Add(array[i - 0]);
                        lastIndexIdList.Add(item);
                    }
                }
                if (array[0] == lastVertexId)
                {
                    var item = new RecognizedPrimitiveIndex(lastVertexId, 0 - 0);
                    item.IndexIdList.Add(array[length - 1]);
                    item.IndexIdList.Add(array[0 - 0]);
                    lastIndexIdList.Add(item);
                }
            }

            return lastIndexIdList;
        }

        public override List<RecognizedPrimitiveIndex> Recognize(
            uint lastVertexId, IntPtr pointer, OneIndexBufferPtr oneIndexBufferPtr, uint primitiveRestartIndex)
        {
            var lastIndexIdList = new List<RecognizedPrimitiveIndex>();
            int length = oneIndexBufferPtr.Length;
            unsafe
            {
                var array = (uint*)pointer.ToPointer();
                for (uint i = 1; i < length; i++)
                {
                    if (array[i - 0] == lastVertexId)
                    {
                        if (array[i - 1] != primitiveRestartIndex)
                        {
                            var item = new RecognizedPrimitiveIndex(lastVertexId, i - 0);
                            item.IndexIdList.Add(array[i - 1]);
                            item.IndexIdList.Add(array[i - 0]);
                            lastIndexIdList.Add(item);
                        }
                    }
                }
                if (array[0] == lastVertexId)
                {
                    if (array[length - 1] != primitiveRestartIndex)
                    {
                        var item = new RecognizedPrimitiveIndex(lastVertexId, 0 - 0);
                        item.IndexIdList.Add(array[length - 1]);
                        item.IndexIdList.Add(array[0 - 0]);
                        lastIndexIdList.Add(item);
                    }
                }
            }

            return lastIndexIdList;
        }

    }
}<commit_msg>LineLoopRecognizer<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CSharpGL
{
    class LineLoopRecognizer : PrimitiveRecognizer
    {
        public override List<RecognizedPrimitiveIndex> Recognize(
            uint lastVertexId, IntPtr pointer, OneIndexBufferPtr oneIndexBufferPtr)
        {
            var lastIndexIdList = new List<RecognizedPrimitiveIndex>();
            switch (oneIndexBufferPtr.Type)
            {
                case IndexElementType.UnsignedByte:
                    RecognizeByte(lastVertexId, pointer, oneIndexBufferPtr, lastIndexIdList);
                    break;
                case IndexElementType.UnsignedShort:
                    RecognizeUShort(lastVertexId, pointer, oneIndexBufferPtr, lastIndexIdList);
                    break;
                case IndexElementType.UnsignedInt:
                    RecognizeUInt(lastVertexId, pointer, oneIndexBufferPtr, lastIndexIdList);
                    break;
                default:
                    throw new NotImplementedException();
            }

            return lastIndexIdList;
        }

        private void RecognizeByte(uint lastVertexId, IntPtr pointer, OneIndexBufferPtr oneIndexBufferPtr, List<RecognizedPrimitiveIndex> lastIndexIdList)
        {
            int length = oneIndexBufferPtr.Length;
            unsafe
            {
                var array = (byte*)pointer.ToPointer();
                for (uint i = 1; i < length; i++)
                {
                    if (array[i - 0] == lastVertexId)
                    {
                        var item = new RecognizedPrimitiveIndex(lastVertexId, i - 0);
                        item.IndexIdList.Add(array[i - 1]);
                        item.IndexIdList.Add(array[i - 0]);
                        lastIndexIdList.Add(item);
                    }
                }
                if (array[0] == lastVertexId)
                {
                    var item = new RecognizedPrimitiveIndex(lastVertexId, 0 - 0);
                    item.IndexIdList.Add(array[length - 1]);
                    item.IndexIdList.Add(array[0 - 0]);
                    lastIndexIdList.Add(item);
                }
            }
        }

        private void RecognizeUShort(uint lastVertexId, IntPtr pointer, OneIndexBufferPtr oneIndexBufferPtr, List<RecognizedPrimitiveIndex> lastIndexIdList)
        {
            int length = oneIndexBufferPtr.Length;
            unsafe
            {
                var array = (ushort*)pointer.ToPointer();
                for (uint i = 1; i < length; i++)
                {
                    if (array[i - 0] == lastVertexId)
                    {
                        var item = new RecognizedPrimitiveIndex(lastVertexId, i - 0);
                        item.IndexIdList.Add(array[i - 1]);
                        item.IndexIdList.Add(array[i - 0]);
                        lastIndexIdList.Add(item);
                    }
                }
                if (array[0] == lastVertexId)
                {
                    var item = new RecognizedPrimitiveIndex(lastVertexId, 0 - 0);
                    item.IndexIdList.Add(array[length - 1]);
                    item.IndexIdList.Add(array[0 - 0]);
                    lastIndexIdList.Add(item);
                }
            }
        }

        private void RecognizeUInt(uint lastVertexId, IntPtr pointer, OneIndexBufferPtr oneIndexBufferPtr,
            List<RecognizedPrimitiveIndex> lastIndexIdList)
        {
            int length = oneIndexBufferPtr.Length;
            unsafe
            {
                var array = (uint*)pointer.ToPointer();
                for (uint i = 1; i < length; i++)
                {
                    if (array[i - 0] == lastVertexId)
                    {
                        var item = new RecognizedPrimitiveIndex(lastVertexId, i - 0);
                        item.IndexIdList.Add(array[i - 1]);
                        item.IndexIdList.Add(array[i - 0]);
                        lastIndexIdList.Add(item);
                    }
                }
                if (array[0] == lastVertexId)
                {
                    var item = new RecognizedPrimitiveIndex(lastVertexId, 0 - 0);
                    item.IndexIdList.Add(array[length - 1]);
                    item.IndexIdList.Add(array[0 - 0]);
                    lastIndexIdList.Add(item);
                }
            }
        }

        public override List<RecognizedPrimitiveIndex> Recognize(
            uint lastVertexId, IntPtr pointer, OneIndexBufferPtr oneIndexBufferPtr, uint primitiveRestartIndex)
        {
            var lastIndexIdList = new List<RecognizedPrimitiveIndex>();
            switch (oneIndexBufferPtr.Type)
            {
                case IndexElementType.UnsignedByte:
                    RecognizeByte(lastVertexId, pointer, oneIndexBufferPtr, lastIndexIdList, primitiveRestartIndex);
                    break;
                case IndexElementType.UnsignedShort:
                    RecognizeUShort(lastVertexId, pointer, oneIndexBufferPtr, lastIndexIdList, primitiveRestartIndex);
                    break;
                case IndexElementType.UnsignedInt:
                    RecognizeUInt(lastVertexId, pointer, oneIndexBufferPtr, lastIndexIdList, primitiveRestartIndex);
                    break;
                default:
                    throw new NotImplementedException();
            }

            return lastIndexIdList;
        }

        private void RecognizeByte(uint lastVertexId, IntPtr pointer, OneIndexBufferPtr oneIndexBufferPtr, List<RecognizedPrimitiveIndex> lastIndexIdList, uint primitiveRestartIndex)
        {
            int length = oneIndexBufferPtr.Length;
            unsafe
            {
                var array = (byte*)pointer.ToPointer();
                for (uint i = 1; i < length; i++)
                {
                    if (array[i - 0] == lastVertexId)
                    {
                        if (array[i - 1] != primitiveRestartIndex)
                        {
                            var item = new RecognizedPrimitiveIndex(lastVertexId, i - 0);
                            item.IndexIdList.Add(array[i - 1]);
                            item.IndexIdList.Add(array[i - 0]);
                            lastIndexIdList.Add(item);
                        }
                    }
                }
                if (array[0] == lastVertexId)
                {
                    if (array[length - 1] != primitiveRestartIndex)
                    {
                        var item = new RecognizedPrimitiveIndex(lastVertexId, 0 - 0);
                        item.IndexIdList.Add(array[length - 1]);
                        item.IndexIdList.Add(array[0 - 0]);
                        lastIndexIdList.Add(item);
                    }
                }
            }
        }

        private void RecognizeUShort(uint lastVertexId, IntPtr pointer, OneIndexBufferPtr oneIndexBufferPtr, List<RecognizedPrimitiveIndex> lastIndexIdList, uint primitiveRestartIndex)
        {
            int length = oneIndexBufferPtr.Length;
            unsafe
            {
                var array = (ushort*)pointer.ToPointer();
                for (uint i = 1; i < length; i++)
                {
                    if (array[i - 0] == lastVertexId)
                    {
                        if (array[i - 1] != primitiveRestartIndex)
                        {
                            var item = new RecognizedPrimitiveIndex(lastVertexId, i - 0);
                            item.IndexIdList.Add(array[i - 1]);
                            item.IndexIdList.Add(array[i - 0]);
                            lastIndexIdList.Add(item);
                        }
                    }
                }
                if (array[0] == lastVertexId)
                {
                    if (array[length - 1] != primitiveRestartIndex)
                    {
                        var item = new RecognizedPrimitiveIndex(lastVertexId, 0 - 0);
                        item.IndexIdList.Add(array[length - 1]);
                        item.IndexIdList.Add(array[0 - 0]);
                        lastIndexIdList.Add(item);
                    }
                }
            }
        }

        private void RecognizeUInt(uint lastVertexId, IntPtr pointer, OneIndexBufferPtr oneIndexBufferPtr, List<RecognizedPrimitiveIndex> lastIndexIdList, uint primitiveRestartIndex)
        {
            int length = oneIndexBufferPtr.Length;
            unsafe
            {
                var array = (uint*)pointer.ToPointer();
                for (uint i = 1; i < length; i++)
                {
                    if (array[i - 0] == lastVertexId)
                    {
                        if (array[i - 1] != primitiveRestartIndex)
                        {
                            var item = new RecognizedPrimitiveIndex(lastVertexId, i - 0);
                            item.IndexIdList.Add(array[i - 1]);
                            item.IndexIdList.Add(array[i - 0]);
                            lastIndexIdList.Add(item);
                        }
                    }
                }
                if (array[0] == lastVertexId)
                {
                    if (array[length - 1] != primitiveRestartIndex)
                    {
                        var item = new RecognizedPrimitiveIndex(lastVertexId, 0 - 0);
                        item.IndexIdList.Add(array[length - 1]);
                        item.IndexIdList.Add(array[0 - 0]);
                        lastIndexIdList.Add(item);
                    }
                }
            }
        }

    }
}
{'fraction_non_alphanumeric': 0.08233249051833122, 'fraction_numerical': 0.007585335018963337, 'mean_word_length': 1.1935875216637781, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '263118', 'n_tokens_mistral': 3260, 'n_tokens_neox': 2997, 'n_words': 597}