当前位置: 首页>>代码示例>>C#>>正文


C# AType.Add方法代码示例

本文整理汇总了C#中AType.Add方法的典型用法代码示例。如果您正苦于以下问题:C# AType.Add方法的具体用法?C# AType.Add怎么用?C# AType.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AType的用法示例。


在下文中一共展示了AType.Add方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: VectorIndexing

        /// <summary>
        /// 
        /// </summary>
        /// <param name="indexers">List containing all of the indexes</param>
        /// <param name="indexpos"></param>
        /// <param name="currentIdx">Array containing the current indexes</param>
        /// <returns></returns>
        public static AType VectorIndexing(this AType input, List<AType> indexers, int indexpos, AType currentIdx, bool isAssign, bool isMemoryMapped)
        {
            if (currentIdx.Length == 0)
            {
                // A Null item found!, select all of the current items
                for (int i = 0; i < input.Length; i++)
                {
                    currentIdx.Add(AInteger.Create(i));
                }
            }

            // Create an array for the results
            AType result = AArray.Create(input.Type);

            // Iterate over the indexes
            foreach (AType index in currentIdx)
            {
                AType item =
                    index.IsArray ?
                    input.VectorIndexing(indexers, indexpos, index, isAssign, isMemoryMapped) :
                    input.SimpleIndex(indexers, indexpos, index, isAssign, isMemoryMapped);

                result.AddWithNoUpdate(item);
            }

            result.UpdateInfo();
            return result;
        }
开发者ID:sammoorhouse,项目名称:aplusdotnet,代码行数:35,代码来源:Utils.cs

示例2: CalculateIndexes

        private static AType CalculateIndexes(AType value, AType target, Aplus environment, out AType indexes)
        {
            if (target.Rank == 0)
            {
                throw new Error.Rank("assign");
            }

            if (!Utils.DifferentNumberType(target, value) && target.Type != value.Type)
            {
                // The target and value are not numbers and they are of a different type?
                throw new Error.Type("assign");
            }

            int currentLength = target.Length;

            if (target.Shape.SequenceEqual<int>(value.Shape))
            {
                indexes = AArray.Create(ATypes.AInteger);

                for (int i = 0; i < value.Length; i++)
                {
                    indexes.Add(AInteger.Create(currentLength));
                    currentLength++;
                }
            }
            else if (target.Shape.GetRange(1, target.Shape.Count - 1).SequenceEqual<int>(value.Shape))
            {
                indexes = AInteger.Create(currentLength);
                currentLength++;
            }
            else if (value.Rank == 0)
            {
                indexes = AInteger.Create(currentLength);
                currentLength++;
            }
            else if (value.Rank == target.Rank)
            {
                indexes = AArray.Create(ATypes.AInteger);

                for (int i = 0; i < value.Length; i++)
                {
                    indexes.Add(AInteger.Create(currentLength));
                    currentLength++;
                }
            }
            else
            {
                throw new Error.Length("assign");
            }

            indexes = ABox.Create(indexes);

            return value;
        }
开发者ID:sammoorhouse,项目名称:aplusdotnet,代码行数:54,代码来源:Assign.cs

示例3: AppendItem

        private static AType AppendItem(AType value, AType target, Aplus environment)
        {
            if (target.Rank == 0)
            {
                throw new Error.Rank("assign");
            }

            if (!Utils.DifferentNumberType(target, value) && target.Type != value.Type)
            {
                // The target and value are not numbers and they are of a different type?
                throw new Error.Type("assign");
            }

            if (target.Shape.SequenceEqual<int>(value.Shape))
            {
                for (int i = 0; i < value.Length; i++)
                {
                    target.Add(value[i].Clone());
                }
            }
            else if (target.Shape.GetRange(1, target.Shape.Count - 1).SequenceEqual<int>(value.Shape))
            {
                target.Add(value.Clone());
            }
            else if (value.Rank == 0)
            {
                AType item = DyadicFunctionInstance.Reshape.Execute(
                    value,
                    target.Shape.GetRange(1, target.Shape.Count - 1).ToAArray()
                );
                target.Add(item);
            }
            else if (value.Rank == target.Rank)
            {
                for (int i = 0; i < value.Length; i++)
                {
                    target.Add(value[i].Clone());
                }
            }
            else
            {
                throw new Error.Length("assign");
            }

            return value;
        }
开发者ID:sammoorhouse,项目名称:aplusdotnet,代码行数:46,代码来源:Assign.cs


注:本文中的AType.Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。