/// <summary>
 /// Initializes a new instance of the <see cref="SmallDocumentBlockList"/> class.
 /// </summary>
 /// <param name="blocks">a list of SmallDocumentBlock instances</param>
 public SmallDocumentBlockList(IList blocks)
 {
     SmallDocumentBlock[] array = new SmallDocumentBlock[blocks.Count];
     blocks.CopyTo(array, 0);
     ListManagedBlock[] tmp = (ListManagedBlock[])array;
     this.SetBlocks(ref tmp);
 }
Example #2
1
 internal SignatureAnalysis(string text, int paramIndex, IList<ISignature> signatures)
 {
     _text = text;
     _paramIndex = paramIndex;
     _signatures = new ISignature[signatures.Count];
     signatures.CopyTo(_signatures, 0);
     Array.Sort(_signatures, (x, y) => x.Parameters.Count - y.Parameters.Count);
 }
Example #3
1
 internal SignatureAnalysis(string text, int paramIndex, IList<ISignature> signatures, string lastKeywordArgument = null) {
     _text = text;
     _paramIndex = paramIndex;
     _signatures = new ISignature[signatures.Count];
     signatures.CopyTo(_signatures, 0);
     _lastKeywordArgument = lastKeywordArgument;
     Array.Sort(_signatures, (x, y) => x.Parameters.Count - y.Parameters.Count);
 }
Example #4
1
        // Initialize for searching a list of values
		public InElement(ExpressionElement operand, IList listElements)
		{
			MyOperand = operand;

			ExpressionElement[] arr = new ExpressionElement[listElements.Count];
			listElements.CopyTo(arr, 0);

			MyArguments = new List<ExpressionElement>(arr);
			this.ResolveForListSearch();
		}
 private ReactiveDownloader
     (IList<OneSongHeader> Songs, String UserAgent, String FolderPath, Boolean GenerateNewFilenames, String FilenameTemplate)
 {
     this._songs = new OneSongHeader[Songs.Count];
     Songs.CopyTo(this._songs, 0);
     this._userAgent = UserAgent;
     this._folderPath = FolderPath;
     this._generateNewFilenames = GenerateNewFilenames;
     this._filenameTemplate = FilenameTemplate;
 }
Example #6
1
 public PersonArray(IList<Person> mdos)
 {
     if (mdos == null || mdos.Count <= 0)
     {
         return;
     }
     Person[] ary = new Person[mdos.Count];
     mdos.CopyTo(ary, 0);
     setProps(ary);
 }
Example #7
1
 public UserArray(IList<User> mdo)
 {
     if (mdo == null || mdo.Count == 0)
     {
         return;
     }
     User[] userAry = new User[mdo.Count];
     mdo.CopyTo(userAry, 0);
     buildArray(userAry);
 }
        private string[] ListToArray(IList<string> stringList)
        {
            if (null == stringList)
            {
                return null;
            }

            string[] stringArray = new string[stringList.Count];
            stringList.CopyTo(stringArray, 0);
            return stringArray;
        }
        public void Contain_All_The_Same_Items(IList<int> inputData)
        {
            int[] initialData = new int[inputData.Count];
            inputData.CopyTo(initialData, 0);

            inputData.RandomShuffle();

            foreach (var initialItem in initialData)
            {
                Assert.That(inputData, Contains.Item(initialItem));
            }
        }
Example #10
1
		internal Reduction(Rule rule, IList<Token> tokens): base() {
			if (rule == null) {
				throw new ArgumentNullException("rule");
			}
			if (tokens == null) {
				throw new ArgumentNullException("tokens");
			}
			this.rule = rule;
			Token[] tokenArray = new Token[tokens.Count];
			tokens.CopyTo(tokenArray, 0);
			this.tokens = Array.AsReadOnly(tokenArray);
		}
 public DataPointSelectionChangedEventArgs(IList<DataPoint> removedItems, IList<DataPoint> addedItems)
 {
     if (addedItems != null)
     {
         this._addedItems = new DataPoint[addedItems.Count];
         addedItems.CopyTo(this._addedItems, 0);
     }
     if (removedItems == null)
         return;
     this._removedItems = new DataPoint[removedItems.Count];
     removedItems.CopyTo(this._removedItems, 0);
 }
 internal static bool FindBestConstructor(Type t, IList<object> parameters, out ConstructorInfo constructorInfo, out object[] convertedParameters)
 {
   MethodBase methodBase;
   object[] parameterObjects = new object[parameters.Count];
   parameters.CopyTo(parameterObjects, 0);
   if (ReflectionHelper.FindBestMember(t.GetConstructors(), parameterObjects, out methodBase, out convertedParameters))
   {
     constructorInfo = (ConstructorInfo) methodBase;
     return true;
   }
   constructorInfo = null;
   return false;
 }
 private XmlNodeList GetAttributesFrom(XmlNode node, IList<string> arguments, bool warnIfEmpty)
 {
     string[] array = new string[arguments.Count];
     arguments.CopyTo(array, 0);
     string xpath = "@" + string.Join("|@", array);
     XmlNodeList xmlNodeList = node.SelectNodes(xpath);
     if (xmlNodeList.Count == 0 && warnIfEmpty && arguments.Count == 1)
         this.Log.LogWarning("Argument '{0}' did not match any attributes", new object[1]
     {
       (object) arguments[0]
     });
     return xmlNodeList;
 }
        public async Task<int> ThinkAsync(IList<char> gameBoard)
        {
            // Copy the contents of the IList to a string.
            char[] arrayTmp = new char[9];
            gameBoard.CopyTo(arrayTmp, 0);
            string board = new String(arrayTmp);

            // Frequently take the center square if the board is empty.
            System.Random random = new System.Random((int)System.DateTime.Now.Ticks);
            if (random.Next() % 2 == 0 && gameBoard.All<char>((ch) => ch == m_emptySymbol.Symbol))
            {
                return 4;
            }

            // Approximate counts of iterations the algorithm makes for each number of available moves at the root level.
            uint[] allIterations = { 0u, 2u, 5u, 15u, 50u, 200u, 930u, 7300u, 60000u, 550000u };
            var moves = MiniMax.AvailableMoves(board, m_emptySymbol.Symbol);
            uint totalIterations = allIterations[moves.Length - 1];

            // Report every 1%.
            uint nextReportIter = totalIterations / 100;
            uint iterBy = nextReportIter;

            // This is called on every iteration of the minimax algorithm.
            MiniMax.CallBackFn callback = /*[total_iterations, &next_report_iter, iter_by, reporter]*/(int iter_count) =>
            {
                if (iter_count == nextReportIter)
                {
                    double progress = 100.0 * iter_count / totalIterations;
                    //reporter.report(Math.Min(progress, 100.0));
                    nextReportIter += iterBy;
                }
            };

            // Run the minimax algorithm in parallel if there are enough iterations.
            // Otherwise, run it serially, as the overhead of parallelism may not benefit.
            int iterCount = 0;
            System.Tuple<int, int> t;
            //if (totalIterations > 500)
            //{
            //    t = parallel_minimax(board, m_symbol, m_opponentSymbol, m_emptySymbol, m_symbol, iterCount, callback);
            //}
            //else
            //{
            t = await MiniMax.Minimax(board, m_symbol.Symbol, m_opponentSymbol.Symbol, m_emptySymbol.Symbol, m_symbol.Symbol, iterCount, callback);
            //}

            // Return the index part.
            return t.Item1;
        }
Example #15
0
        public TaggedAppointmentArray(string tag, IList<Appointment> mdos)
        {
            if (mdos == null || mdos.Count == 0)
            {
                this.count = 0;
                return;
            }

            Appointment[] appts = new Appointment[mdos.Count];
            mdos.CopyTo(appts, 0);

            initialize(tag, appts);
        }
    public SelectionChangedEventArgs(RoutedEvent id, IList removedItems, IList addedItems) :
      base(id)
    {
      if (removedItems == null)
        throw new ArgumentNullException("removedItems");
      if (addedItems == null)
        throw new ArgumentNullException("addedItems");

      RemovedItems = new object[removedItems.Count];
      removedItems.CopyTo((Array) RemovedItems, 0);

      AddedItems = new object[addedItems.Count];
      addedItems.CopyTo((Array) AddedItems, 0);
    }
        /// <summary>
        /// Lists all subscribers for the specified message types
        /// </summary>
        /// <param name="messageTypes"></param>
        /// <returns></returns>
        public IList<string> GetSubscribersForMessage(IList<string> messageTypes)
        {
            var mt = new string[messageTypes.Count];
            messageTypes.CopyTo(mt, 0);

            using (var session = sessionSource.CreateSession())
            {
                return session.CreateCriteria(typeof(Subscription))
                                    .Add(Restrictions.In("MessageType", mt))
                                    .SetProjection(Projections.Property("SubscriberEndpoint"))
                                    .SetResultTransformer(new DistinctRootEntityResultTransformer())
                                    .List<string>();
            }
        }
 public SelectionChangedEventArgs(IList removedItems, IList addedItems)
 {
     if (removedItems == null)
     {
         throw new ArgumentNullException("removedItems");
     }
     if (addedItems == null)
     {
         throw new ArgumentNullException("addedItems");
     }
     this.removedItems = new object[removedItems.Count];
     removedItems.CopyTo(this.removedItems, 0);
     this.addedItems = new object[addedItems.Count];
     addedItems.CopyTo(this.addedItems, 0);
 }
Example #19
0
 /// <summary> 
 /// Initializes a new instance of a SelectionChangedEventArgs class.
 /// </summary> 
 /// <param name="removedItems">The items that were unselected during this event.</param>
 /// <param name="addedItems">The items that were selected during this event.</param>
 public SelectionChangedEventArgs(IList removedItems, IList addedItems) 
 {
     if (null == removedItems)
     { 
         throw new ArgumentNullException("removedItems"); 
     }
     if (null == addedItems) 
     {
         throw new ArgumentNullException("addedItems");
     } 
     _removedItems = new object[removedItems.Count];
     removedItems.CopyTo(_removedItems, 0);
     _addedItems = new object[addedItems.Count]; 
     addedItems.CopyTo(_addedItems, 0); 
 }
        private XmlNodeList GetAttributesFrom(XmlNode node, IList<string> arguments, bool warnIfEmpty) {
            string[] array = new string[arguments.Count];
            arguments.CopyTo(array, 0);
            string xpath = String.Concat("@", String.Join("|@", array));
            
            XmlNodeList attributes = node.SelectNodes(xpath);
            if (attributes.Count == 0 && warnIfEmpty) {
                Debug.Assert(arguments.Count == 1, "Should only call warnIfEmpty==true with one argument");
                if (arguments.Count == 1) {
                    Log.LogWarning(SR.XMLTRANSFORMATION_TransformArgumentFoundNoAttributes, arguments[0]);
                }
            }

            return attributes;
        }
 public object InstantiateElement(IParserContext context, string typeName, IList<object> parameters)
 {
   try
   {
     Type t = GetElementType(typeName);
     object[] parameterObjects = new object[parameters.Count];
     parameters.CopyTo(parameterObjects, 0);
     return Activator.CreateInstance(t, parameterObjects);
   }
   catch (Exception e)
   {
     if (e is XamlParserException)
       throw;
     throw new XamlParserException("Error creating element type '{0}'", e, typeName);
   }
 }
Example #22
0
        /// <summary>
        /// Creates a new Program
        /// </summary>
        /// <param name="processor">the processor for this program</param>
        /// <param name="instructions">the program instructions</param>
        /// <param name="debugInfo">optional program debug information</param>
        public Program(Processor processor, IList<IInstruction> instructions,
                        ProgramDebugInfo debugInfo = null)
        {
            this.DebugInfo = debugInfo;
            this.Processor = processor;

            // Check instructions size
            if (instructions.Count > processor.RomSize)
            {
                throw new ArgumentException("Number of instructions > size of instruction ROM");
            }

            // Create new readonly instructions array
            IInstruction[] instructionArray = new IInstruction[processor.RomSize];
            instructions.CopyTo(instructionArray, 0);
            this.Instructions = new ReadOnlyCollection<IInstruction>(instructionArray);
        }
 public void SetSteps(Transform chess, IList t)
 {
     Chess = chess;
     tower = GetClosetChess(Chess);
     cPass = Chess.GetComponent<CharacterPassive>();
     chessModel = chess.FindChild("Models");
     if(chessModel.GetComponent<AnimVault>()!=null){
         //chessModel.GetComponent<AnimVault>().CurrentState = AnimVault.AnimState.run;
         currentSelect.AnimStateNetWork(chess, AnimVault.AnimState.run);
     }
     int len = t.Count;
     pathList = new Transform[len];
     t.CopyTo(pathList,0);
     Step = pathList.Length-1;
     if(Step>0){
         SetDestination();
     }
 }
Example #24
0
        /// <summary>
        ///     Sets header info for this branch.
        /// </summary>
        internal void SetHeaderInfo(IList childBranchList, TreeGridDesignerColumnDescriptor[] columns)
        {
            if (childBranchList == null)
            {
                throw new ArgumentNullException("childBranchList");
            }

            _childBranchArray = new ChildBranchInfo[childBranchList.Count];
            childBranchList.CopyTo(_childBranchArray, 0);

            _columns = columns;

            _currentBranches = new List<ChildBranchInfo>(_childBranchArray.Length);
            for (var i = 0; i < _childBranchArray.Length; i++)
            {
                _currentBranches.Add(_childBranchArray[i]);
            }
        }
Example #25
0
        private AllSprites( Context context, AllSpriteAttributes attrs, SpriteFileLocations locs, IList<Sprite> otherSprites )
        {
            Count = attrs.Count + otherSprites.Count;
            sprites = new Sprite[Count];
            IList<string> spriteNames = context == Context.US_PSP ? PSPResources.Lists.SpriteFiles : PSXResources.Lists.SpriteFiles;
            for (int i = 0; i < attrs.Count; i++)
            {
                sprites[i] = new CharacterSprite(
                    context,
                    string.Format( "{0:X2} - {1}", i+1, spriteNames[i] ),
                    attrs[i],
                    locs[i] );
            }
            otherSprites.CopyTo( sprites, attrs.Count );

            this.attrs = attrs;
            this.locs = locs;

            Dictionary<Sprite, IList<int>> sharedSPRs = new Dictionary<Sprite, IList<int>>();
            for (int i = 0; i < sprites.Count; i++)
            {
                sharedSPRs.Add( sprites[i], new List<int>() );
            }

            for (int i = 0; i < attrs.Count; i++)
            {
                for (int j = i + 1; j < attrs.Count; j++)
                {
                    if (locs[i].Sector == locs[j].Sector)
                    {
                        sharedSPRs[sprites[i]].Add( j );
                        sharedSPRs[sprites[j]].Add( i );
                    }
                }
            }

            for (int i = 0; i < sprites.Count; i++)
            {
                sharedSPRs[sprites[i]].Sort();
                sharedSPRs[sprites[i]] = sharedSPRs[sprites[i]].AsReadOnly();
            }

            SharedSPRs = new ReadOnlyDictionary<Sprite, IList<int>>( sharedSPRs );
        }
        /// <summary>
        /// The constructor for selection changed args
        /// </summary>
        /// <param name="id">The event ID for the event about to fire -- should probably be Selector.SelectionChangedEvent</param>
        /// <param name="removedItems">The items that were unselected during this event</param>
        /// <param name="addedItems">The items that were selected during this event</param>
        public SelectionChangedEventArgs(
            RoutedEvent id,
            IList removedItems,
            IList addedItems)
        {
            if (id == null)
                throw new ArgumentNullException("id");
            if (removedItems == null)
                throw new ArgumentNullException("removedItems");
            if (addedItems == null)
                throw new ArgumentNullException("addedItems");

            RoutedEvent = id;

            _removedItems = new object[removedItems.Count];
            removedItems.CopyTo(_removedItems, 0);

            _addedItems = new object[addedItems.Count];
            addedItems.CopyTo(_addedItems, 0);
        }
Example #27
0
        protected AbstractFile( GenericCharMap charmap, FFTPatcher.TextEditor.FFTTextFactory.FileInfo layout, string fileComments, IList<string> sectionComments, bool compressible )
        {
            System.Diagnostics.Debug.Assert( sectionComments.Count == layout.SectionNames.Count );
            FileComments = fileComments ?? string.Empty;
            SectionComments = new string[sectionComments.Count];
            sectionComments.CopyTo( SectionComments, 0 );

            NumberOfSections = layout.SectionLengths.Count;
            Layout = layout;
            CharMap = charmap;
            SelectedTerminator = layout.AllowedTerminators[0];
            EntryNames = layout.EntryNames.AsReadOnly();
            SectionLengths = layout.SectionLengths.AsReadOnly();
            SectionNames = layout.SectionNames.AsReadOnly();
            HiddenEntries = layout.Hidden.AsReadOnly();
            DisplayName = layout.DisplayName;
            Compressible = compressible;
            CompressionAllowed = layout.CompressionAllowed.AsReadOnly();
            DteAllowed = layout.DteAllowed.AsReadOnly();
        }
        // Handles the lists of elements.
        protected CombinatorialBase(IList listObjects, int nKlass )
        {
            // Check the validity of the arguments
            DoArgumentCheck(listObjects.Count, nKlass);

            m_nKlass = nKlass;

            // Always takes the ZERO (FIRST) dimension of the array. There is no
            // problem in manipulation multidimensional arrays.
            m_nMaxIndex = listObjects.Count - 1;

            m_arrayIndeces = new int[m_nKlass];
            m_arrayIndecesDummy = new int[m_nKlass];

            m_arrayCurrentObj = new Object[m_nKlass];

            // Make a shallow copy of the source array.
            //			m_arrayObj = Array.CreateInstance(listObjects[0].GetType(), listObjects.Count);
            m_arrayObj = Array.CreateInstance(Type.GetType("System.Object"), listObjects.Count);
            listObjects.CopyTo(m_arrayObj, 0);
        }
Example #29
0
 static void BuildInputHelper(int column, IList<object> data, ref List<object[]> input)
 {
     if (column == data.Count)
       {
     object[] items= new object[data.Count];
     data.CopyTo(items,0);
     input.Add(items);
     return;
       }
       var list = data[column] as System.Collections.IList;
       if (list != null)
       {
     foreach (var item in list)
     {
       data[column] = item;
       BuildInputHelper(column + 1, data, ref input);
     }
     data[column] = list;
       }
       else
     BuildInputHelper(column + 1, data, ref input);
 }
        private void SetCollectionValues(Array a, IList listValue) {
            
            try {
                if (collection != null) {
                   collection.Locked = true;
                }

                // now we have to copy the value into each property.
                object[] values = new object[listValue.Count];
                
                listValue.CopyTo(values, 0);
                
                for (int i = 0; i < descriptors.Length; i++) {
                    IList propList = descriptors[i].GetValue(GetPropertyOwnerForComponent(a, i)) as IList;

                    if (propList == null) {
                       continue;
                    }
                    
                    propList.Clear();
                    foreach (object val in values) {
                        propList.Add(val);
                    }
                }
            }
            finally {
               if (collection != null) {
                  collection.Locked = false;
               }
            }

        }