// // Copyright (c) APX Labs, Inc. All rights reserved. // // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. using System; using System.Collections.Generic; namespace ApxLabs.FastAndroidCamera { internal class FastJavaByteArrayEnumerator : IEnumerator { internal FastJavaByteArrayEnumerator(FastJavaByteArray arr) { if (arr == null) throw new ArgumentNullException(); _arr = arr; _idx = 0; } /// /// Gets the current byte in the collection. /// public byte Current { get { byte retval; unsafe { // get value from pointer retval = _arr.Raw[_idx]; } return retval; } } /// /// Releases all resource used by the object. /// /// Call when you are finished using the /// . The method leaves the /// in an unusable state. After calling /// , you must release all references to the /// so the garbage collector can reclaim the /// memory that the was occupying. public void Dispose() { } /// /// Advances the enumerator to the next element of the collection. /// /// true if the enumerator was successfully advanced to the next element; false if the enumerator has passed the end of the collection. public bool MoveNext() { if (_idx > _arr.Count) return false; ++_idx; return _idx < _arr.Count; } /// /// Sets the enumerator to its initial position, which is before the first element in the collection. /// public void Reset() { _idx = 0; } #region IEnumerator implementation /// /// Gets the current element in the collection. /// /// The system. collections. IE numerator. current. object System.Collections.IEnumerator.Current { get { byte retval; unsafe { // get value from pointer retval = _arr.Raw[_idx]; } return retval; } } #endregion FastJavaByteArray _arr; int _idx; } }