code: function(start, end) {
  			var annotations = this._annotations, current;
  			var i = 0, skip;
  			if (start === undefined && end === undefined) {
  				skip = function() {
  					return (i < annotations.length) ? annotations[i++] : null;
  				};
  			} else {
  				//TODO binary search does not work for range intersection when there are overlaping ranges, need interval search tree for this
  				skip = function() {
  					while (i < annotations.length) {
  						var a =  annotations[i++];
  						if ((start === a.start) || (a.start === a.end && a.end === end) || (start > a.start ? start < a.end : a.start < end)) {
  							return a;
  						}
  						if (a.start >= end) {
  							break;
  						}
  					}
  					return null;
  				};
  			}
  			current = skip();
  			return {
  				next: function() {
  					var result = current;
  					if (result) { current = skip(); }
  					return result;
  				},
  				hasNext: function() {
  					return current !== null;
  				}
  			};
  		}
docs: @class This object represents an annotation iterator.
  <p>
  <b>See:</b><br/>
  {@link orion.editor.AnnotationModel#getAnnotations}<br/>
  </p>
  @name orion.editor.AnnotationIterator
  
  @property {Function} hasNext Determines whether there are more annotations in the iterator.
  @property {Function} next Returns the next annotation in the iterator.
   
  Returns an iterator of annotations for the given range of text. If called with no parameters,
  returns all annotations in the model.
  
  @param {Number} start the start offset of the range.
  @param {Number} end the end offset of the range.
  @return {orion.editor.AnnotationIterator} an annotation iterartor.