@Override
	public final MutableObjectIterator<T> getIterator() {
		final SingleSegmentInputView startIn = new SingleSegmentInputView(this.recordsPerSegment * this.recordSize);
		startIn.set(this.sortBuffer.get(0), 0);
		
		return new MutableObjectIterator<T>() {
			
			private final SingleSegmentInputView in = startIn;
			private final TypeComparator<T> comp = comparator;
			
			private final int numTotal = size();
			private final int numPerSegment = recordsPerSegment;
			
			private int currentTotal = 0;
			private int currentInSegment = 0;
			private int currentSegmentIndex = 0;

			@Override
			public T next(T reuse) {
				if (this.currentTotal < this.numTotal) {
					
					if (this.currentInSegment >= this.numPerSegment) {
						this.currentInSegment = 0;
						this.currentSegmentIndex++;
						this.in.set(sortBuffer.get(this.currentSegmentIndex), 0);
					}
					
					this.currentTotal++;
					this.currentInSegment++;
					
					try {
						return this.comp.readWithKeyDenormalization(reuse, this.in);
					}
					catch (IOException ioe) {
						throw new RuntimeException(ioe);
					}
				}
				else {
					return null;
				}
			}

			@Override
			public T next() {
				if (this.currentTotal < this.numTotal) {

					if (this.currentInSegment >= this.numPerSegment) {
						this.currentInSegment = 0;
						this.currentSegmentIndex++;
						this.in.set(sortBuffer.get(this.currentSegmentIndex), 0);
					}

					this.currentTotal++;
					this.currentInSegment++;

					try {
						return this.comp.readWithKeyDenormalization(serializer.createInstance(), this.in);
					}
					catch (IOException ioe) {
						throw new RuntimeException(ioe);
					}
				}
				else {
					return null;
				}
			}
		};
	}
@ Override public final MutableObjectIterator < T > getIterator ( ) { final SingleSegmentInputView startIn = new SingleSegmentInputView ( this . recordsPerSegment * this . recordSize ) ; startIn . set ( this . sortBuffer . get ( 0 ) , 0 ) ; return new MutableObjectIterator < T > ( ) { private final SingleSegmentInputView in = startIn ; private final TypeComparator < T > comp = comparator ; private final int numTotal = size ( ) ; private final int numPerSegment = recordsPerSegment ; private int currentTotal = 0 ; private int currentInSegment = 0 ; private int currentSegmentIndex = 0 ; @ Override public T next ( T reuse ) { if ( this . currentTotal < this . numTotal ) { if ( this . currentInSegment >= this . numPerSegment ) { this . currentInSegment = 0 ; this . currentSegmentIndex ++ ; this . in . set ( sortBuffer . get ( this . currentSegmentIndex ) , 0 ) ; } this . currentTotal ++ ; this . currentInSegment ++ ; try { return this . comp . readWithKeyDenormalization ( reuse , this . in ) ; } catch ( IOException ioe ) { throw new RuntimeException ( ioe ) ; } } else { return null ; } } @ Override public T next ( ) { if ( this . currentTotal < this . numTotal ) { if ( this . currentInSegment >= this . numPerSegment ) { this . currentInSegment = 0 ; this . currentSegmentIndex ++ ; this . in . set ( sortBuffer . get ( this . currentSegmentIndex ) , 0 ) ; } this . currentTotal ++ ; this . currentInSegment ++ ; try { return this . comp . readWithKeyDenormalization ( serializer . createInstance ( ) , this . in ) ; } catch ( IOException ioe ) { throw new RuntimeException ( ioe ) ; } } else { return null ; } } } ; }
Gets an iterator over all records in this buffer in their logical order.

@return An iterator returning the records in their logical order.