On 9/21/2011 4:58 PM, Jörn Kottmann wrote:
> On 9/21/11 5:46 AM, James Kosin wrote:
>> This means one of the endpoints in the span don't attribute to the
>> length of the span.  Is this correct?  Does this mean a span with a
>> start and end say at 1,1 has no length?  Or is it suppose to be 1?
>>
>> I have similar problems when counting the number of locations to fill
>> for a memory block when doing (end - start) type arithmetic.  What
>> happens is the length ends up being one short.
>
> Usually we have an array of items, or a list. The start index is
> always the
> item itself, e.g. 0 means the span begins just at the first item. The end
> index is always the index of the item after the last item in the span.
>
> So if you have just an array of length one, and want to define a span
> which covers it, it would be start=0 and end=1 that results in
> end-start=1.
>
> Jörn
>
The only problem is we define:
>   /**
>    * Returns true if the specified span is contained by this span.
>    * Identical spans are considered to contain each other.
>    *
>    * @param s The span to compare with this span.
>    *
>    * @return true is the specified span is contained by this span;
>    * false otherwise.
>    */
>   public boolean contains(Span s) {
>     return start <= s.getStart() && s.getEnd() <= end;
>   }
>
>   public boolean contains(int index) {
>     return start <= index && index <= end;
>   }
>
The first is okay, but the second definition is a bit odd; since, the
end is included as part of the span when using index as an input.  Is
this correct?

Reply via email to