/// <summary> /// Instantiate new PHP array's enumerator and advances its position to the first element. /// </summary> /// <returns><c>True</c> whether there is an first element.</returns> void InitArrayIteratorHelper() { Debug.Assert(_array != null); _arrayEnumerator = new OrderedDictionary.Enumerator(_array); _isValid = _arrayEnumerator.MoveFirst(); }
/// <summary> /// Copy constructor. Creates <see cref="PhpArray"/> that shares internal data table with another <see cref="PhpArray"/>. /// </summary> /// <param name="array">Table to be shared.</param> /// <param name="preserveMaxInt">True to copy the <see cref="PhpHashtable.MaxIntegerKey"/> from <paramref name="array"/>. /// Otherwise the value will be recomputed when needed. See http://phalanger.codeplex.com/workitem/31484 for more details.</param> public PhpArray(PhpArray /*!*/ array, bool preserveMaxInt) : base(array, preserveMaxInt) { // preserve intrinsic enumerator state _intrinsicEnumerator = array._intrinsicEnumerator?.WithTable(this); // copies state of intrinsic enumerator or null }
/// <summary> /// Instantiate new PHP array's enumerator and advances its position to the first element. /// </summary> /// <returns><c>True</c> whether there is an first element.</returns> protected void InitArrayIteratorHelper() { Debug.Assert(this.array != null); this.arrayEnumerator = new OrderedDictionary.Enumerator(this.array, false); this.isValid = this.arrayEnumerator.MoveFirst(); }
/// <summary> /// Creates a new instance of the enumerator. /// </summary> /// <param name="array">The array to iterate over.</param> public ForeachEnumeratorValues(PhpArray/*!*/ array) { Debug.Assert(array != null); // share the table to iterate through readonly array, // get the enumerator, have to be disposed at the end of enumeration, otherwise deep copy will be performed probably // note (J): this will not result in registering the enumerator in the PhpArray object, not needed, faster this.enumerator = (OrderedDictionary.Enumerator)array.table.Share().GetEnumerator(); }
/// <summary> /// Creates a new instance of the enumerator. /// </summary> /// <param name="array">The array to iterate over.</param> /// <param name="keyed">Whether keys are interesting.</param> public ForeachEnumeratorAliased(PhpArray/*!*/ array, bool keyed) { Debug.Assert(array != null); this.array = array; this.enumerator = new OrderedDictionary.Enumerator(array, true); // ForeachEnumeratorAliased can leave an undisposed enumerator registered in the array object // (only in case a break; was called inside an aliased foreach loop). }