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

namespace HexTiles
{
    /// <summary>
    /// Wrapper around our internal data structure for storing hex tiles.
    /// </summary>
    public interface IHexTileCollection : IEnumerable<HexTile>
    {
        /// <summary>
        /// Add a tile to the collection.
        /// </summary>
        void Add(HexCoords coords, HexTile tile);

        /// <summary>
        /// Remove a tile at the specified coordinates.
        /// </summary>
        void Remove(HexCoords coords);

        /// <summary>
        /// Delete all elements of the collection.
        /// </summary>
        void Clear();

        /// <summary>
        /// Return whether or not our collection contains the specified tile.
        /// </summary>
        bool Contains(HexCoords key);

        /// <summary>
        /// Array accessor.
        /// </summary>
        HexTile this[HexCoords index] { get; }

        /// <summary>
        /// Try to get the value at the specified coordinates and return whether it was successful or not.
        /// </summary>
        bool TryGetValue(HexCoords index, out HexTile tile);

        /// <summary>
        /// Enumerable of all the coordinates stored in this collection.
        /// </summary>
        ICollection<HexCoords> Keys { get; }
    }

    /// <summary>
    /// Wrapper around our internal data structure for storing hex tiles.
    /// </summary>
    class HexTileCollection : IHexTileCollection
    {
        private Hashtable tiles = new Hashtable();

        /// <summary>
        /// Array accessor.
        /// </summary>
        public HexTile this[HexCoords index]
        {
            get
            {
                return (HexTile)tiles[index];
            }
        }

        /// <summary>
        /// Add a tile to the collection.
        /// </summary>
        public void Add(HexCoords coords, HexTile tile)
        {
            tiles.Add(coords, tile);
        }

        /// <summary>
        /// Remove a tile at the specified coordinates.
        /// </summary>
        public void Remove(HexCoords coords)
        {
            tiles.Remove(coords);
        }

        /// <summary>
        /// Delete all elements of the collection.
        /// </summary>
        public void Clear()
        {
            tiles.Clear();
        }

        /// <summary>
        /// Enumerable of all the coordinates stored in this collection.
        /// </summary>
        public ICollection<HexCoords> Keys
        {
            get
            {
                return (ICollection<HexCoords>)tiles.Keys;
            }
        }

        /// <summary>
        /// Return whether or not our collection contains the specified tile.
        /// </summary>
        public bool Contains(HexCoords key)
        {
            return tiles.Contains(key);
        }

        /// <summary>
        /// Try to get the value at the specified coordinates and return whether it was successful or not.
        /// </summary>
        public bool TryGetValue(HexCoords index, out HexTile tile)
        {
            if (tiles.Contains(index))
            {
                tile = (HexTile)tiles[index];
                return true;
            }
            tile = null;
            return false;
        }

        public IEnumerator<HexTile> GetEnumerator()
        {
            foreach (var tile in tiles.Values)
            {
                yield return (HexTile)tile;
            }
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            return GetEnumerator();
        }
    }
}
<commit_msg>Fixed issue where resizing map would throw an exception.<commit_after>﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HexTiles
{
    /// <summary>
    /// Wrapper around our internal data structure for storing hex tiles.
    /// </summary>
    public interface IHexTileCollection : IEnumerable<HexTile>
    {
        /// <summary>
        /// Add a tile to the collection.
        /// </summary>
        void Add(HexCoords coords, HexTile tile);

        /// <summary>
        /// Remove a tile at the specified coordinates.
        /// </summary>
        void Remove(HexCoords coords);

        /// <summary>
        /// Delete all elements of the collection.
        /// </summary>
        void Clear();

        /// <summary>
        /// Return whether or not our collection contains the specified tile.
        /// </summary>
        bool Contains(HexCoords key);

        /// <summary>
        /// Array accessor.
        /// </summary>
        HexTile this[HexCoords index] { get; }

        /// <summary>
        /// Try to get the value at the specified coordinates and return whether it was successful or not.
        /// </summary>
        bool TryGetValue(HexCoords index, out HexTile tile);

        /// <summary>
        /// Enumerable of all the coordinates stored in this collection.
        /// </summary>
        IEnumerable<HexCoords> Keys { get; }
    }

    /// <summary>
    /// Wrapper around our internal data structure for storing hex tiles.
    /// </summary>
    class HexTileCollection : IHexTileCollection
    {
        private Hashtable tiles = new Hashtable();

        /// <summary>
        /// Array accessor.
        /// </summary>
        public HexTile this[HexCoords index]
        {
            get
            {
                return (HexTile)tiles[index];
            }
        }

        /// <summary>
        /// Add a tile to the collection.
        /// </summary>
        public void Add(HexCoords coords, HexTile tile)
        {
            tiles.Add(coords, tile);
        }

        /// <summary>
        /// Remove a tile at the specified coordinates.
        /// </summary>
        public void Remove(HexCoords coords)
        {
            tiles.Remove(coords);
        }

        /// <summary>
        /// Delete all elements of the collection.
        /// </summary>
        public void Clear()
        {
            tiles.Clear();
        }

        /// <summary>
        /// Enumerable of all the coordinates stored in this collection.
        /// </summary>
        public IEnumerable<HexCoords> Keys
        {
            get
            {
                return tiles.Keys.Cast<HexCoords>();
            }
        }

        /// <summary>
        /// Return whether or not our collection contains the specified tile.
        /// </summary>
        public bool Contains(HexCoords key)
        {
            return tiles.Contains(key);
        }

        /// <summary>
        /// Try to get the value at the specified coordinates and return whether it was successful or not.
        /// </summary>
        public bool TryGetValue(HexCoords index, out HexTile tile)
        {
            if (tiles.Contains(index))
            {
                tile = (HexTile)tiles[index];
                return true;
            }
            tile = null;
            return false;
        }

        public IEnumerator<HexTile> GetEnumerator()
        {
            foreach (var tile in tiles.Values)
            {
                yield return (HexTile)tile;
            }
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            return GetEnumerator();
        }
    }
}

{'fraction_non_alphanumeric': 0.10699366662174908, 'fraction_numerical': 0.0, 'mean_word_length': 1.3629417382999045, 'pattern_counts': {'":': 0, '<': 77, '<?xml version=': 0, '>': 77, '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': '5513598', 'n_tokens_mistral': 1905, 'n_tokens_neox': 1850, 'n_words': 576}