<commit_before>/////////////////////////////////////////////////////////////////////////
// Copyright (c) 2014 Something Precious, Inc.
//
// PartialPlane.cs: L̓񎟌`̈\NX
//
// Author:      <NAME> (<EMAIL>)
// Created:     Dec. 07, 2014
// Last update: Dec. 09, 2014
/////////////////////////////////////////////////////////////////////////

using System;
using System.Collections.Generic;


namespace CHaser
{
//
// PartialPlanẽNX`
//
public class PartialPlane<T> {
    // RXgN^
    public PartialPlane(T defVal)
    {
        mDefVal = defVal;
        mLeftBottomX = mLeftBottomY = 0;
        mBody = new List<List<T>>();

        // vC[̏Wǉ
        List<T> origin = new List<T>();
        origin.Add(defVal);
        mBody.Add(origin);
    }

    // 
    public int    LeftBottomX { get { return mLeftBottomX; } }
    public int    LeftBottomY { get { return mLeftBottomY; } }
    public int    Width { get { return (mBody[0]).Count; } }
    public int    Height { get { return mBody.Count; } }

    // Pʗ̈̒l̎擾Ɛݒ
    public T    GetValueAt(int x, int y)
    {
        try {
            return (T)((mBody[y - mLeftBottomY])[x - mLeftBottomX]);
        } catch (ArgumentOutOfRangeException) {
            return mDefVal;
        }
    }
    public void    SetValueAt(int x, int y, T val)
    {
        if (! Contains(x, y)) {
            throw (new ArgumentOutOfRangeException());
        }
        (mBody[y - mLeftBottomY])[x - mLeftBottomX] = val;
    }

    // ̈̊Ǘ
    public bool    Contains(int x, int y)
    {
        return ((mLeftBottomX <= x && x < mLeftBottomX + Width)
            && (mLeftBottomY <= y && y < mLeftBottomY + Height));
    }
    public void    ExpandHorizontal(int diffWidth, bool toRight)
    {
        // assertion
        if (diffWidth <= 0) {
            Console.Out.WriteLine("illegal argument for ExpandHorizontal().");
            return;
        }

        int dstPos  = (toRight ? this.Width : 0);
        T[] defVals = new T[diffWidth];

        for (int i = 0; i < diffWidth; ++i) {
            defVals[i] = mDefVal;
        }
        for (int i = 0; i < this.Height; ++i) {
            (mBody[i]).InsertRange(dstPos, defVals);
        }
        if (! toRight) {
            mLeftBottomX -= diffWidth;
        }
    }
    public void ExpandVertical(int diffHeight, bool toTop)
    {
        // assertion
        if (diffHeight <= 0) {
            Console.Out.WriteLine("illegal argument for ExpandVertical().");
            return;
        }

        int dstPos  = (toTop ? Height : 0);
        int width   = this.Width;
        T[] defVals = new T[width];

        for (int i = 0; i < width; ++i) {
            defVals[i] = mDefVal;
        }
        for (int i = 0; i < diffHeight; ++i) {
            List<T> newArray = new List<T>(width);

            newArray.InsertRange(0, defVals);
            mBody.Insert(dstPos, newArray);
        }
        if (! toTop) {
            mLeftBottomY -= diffHeight;
        }
    }

    // f[^o
    private T      mDefVal;         // Pʗ̈̏l
    private int    mLeftBottomX;    // ̈̍̍WixWlj
    private int    mLeftBottomY;    // ̈̍̍WiyWlj
    private List<List<T>> mBody;    // ̈̂\I񎟌z
}
}

//
// End of File
//<commit_msg>use System.Linq.Enumerable to initialize Array/List<commit_after>/////////////////////////////////////////////////////////////////////////
// Copyright (c) 2014-2016 Something Precious, Inc.
//
// PartialPlane.cs: L̓񎟌`̈\NX
//
// Author:      <NAME> (<EMAIL>)
// Created:     Dec. 07, 2014
// Last update: May. 07, 2016
/////////////////////////////////////////////////////////////////////////

using System;
using System.Collections.Generic;
using System.Linq;


namespace CHaser
{
//
// PartialPlanẽNX`
//
public class PartialPlane<T> {
    // RXgN^
    public PartialPlane(T defVal)
    {
        mDefVal = defVal;
        mLeftBottomX = mLeftBottomY = 0;
        mBody = new List<List<T>>();

        // vC[̏Wǉ
        List<T> origin = new List<T>();
        origin.Add(defVal);
        mBody.Add(origin);
    }

    // 
    public int    LeftBottomX { get { return mLeftBottomX; } }
    public int    LeftBottomY { get { return mLeftBottomY; } }
    public int    Width { get { return (mBody[0]).Count; } }
    public int    Height { get { return mBody.Count; } }

    // Pʗ̈̒l̎擾Ɛݒ
    public T    GetValueAt(int x, int y)
    {
        try {
            return (T)((mBody[y - mLeftBottomY])[x - mLeftBottomX]);
        } catch (ArgumentOutOfRangeException) {
            return mDefVal;
        }
    }
    public void    SetValueAt(int x, int y, T val)
    {
        if (! Contains(x, y)) {
            throw (new ArgumentOutOfRangeException());
        }
        (mBody[y - mLeftBottomY])[x - mLeftBottomX] = val;
    }

    // ̈̊Ǘ
    public bool    Contains(int x, int y)
    {
        return ((mLeftBottomX <= x && x < mLeftBottomX + Width)
            && (mLeftBottomY <= y && y < mLeftBottomY + Height));
    }
    public void    ExpandHorizontal(int diffWidth, bool toRight)
    {
        // assertion
        if (diffWidth <= 0) {
            Console.Out.WriteLine("illegal argument for ExpandHorizontal().");
            return;
        }

        int dstPos  = (toRight ? this.Width : 0);
        T[] defVals = Enumerable.Repeat(mDefVal, diffWidth).ToArray();

        foreach (List<T> row in mBody) {
            row.InsertRange(dstPos, defVals);
        }
        if (! toRight) {
            mLeftBottomX -= diffWidth;
        }
    }
    public void ExpandVertical(int diffHeight, bool toTop)
    {
        // assertion
        if (diffHeight <= 0) {
            Console.Out.WriteLine("illegal argument for ExpandVertical().");
            return;
        }

        int dstPos  = (toTop ? Height : 0);
        int width   = this.Width;
        for (int i = 0; i < diffHeight; ++i) {
            mBody.Insert(dstPos, Enumerable.Repeat(mDefVal, width).ToList());
        }
        if (! toTop) {
            mLeftBottomY -= diffHeight;
        }
    }

    // f[^o
    private T      mDefVal;         // Pʗ̈̏l
    private int    mLeftBottomX;    // ̈̍̍WixWlj
    private int    mLeftBottomY;    // ̈̍̍WiyWlj
    private List<List<T>> mBody;    // ̈̂\I񎟌z
}
}

//
// End of File
//
{'fraction_non_alphanumeric': 0.17721110393802453, 'fraction_numerical': 0.008715300193673338, 'mean_word_length': 1.5180820804550996, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 24, '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': '6784684', 'n_tokens_mistral': 2106, 'n_tokens_neox': 2023, 'n_words': 471}