示例#1
0
文件: Arrayx.cs 项目: alvivar/Gigas
    public Arrayx <T> Map(Func <T, T> callback)
    {
        var result = Arrayx <T> .New(Length);

        for (int i = 0; i < Length; i++)
        {
            result.Add(callback(Elements[i]));
        }

        return(result);
    }
示例#2
0
文件: Arrayx.cs 项目: alvivar/Gigas
    public Arrayx <T> Filter(Func <T, bool> callback, bool first = false)
    {
        var result = Arrayx <T> .New(Length);

        for (int i = 0; i < Length; i++)
        {
            if (callback(Elements[i]))
            {
                result.Add(Elements[i]);
                if (first)
                {
                    break;
                }
            }
        }

        return(result);
    }