[ 
https://issues.apache.org/jira/browse/COLLECTIONS-366?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13596973#comment-13596973
 ] 

Thomas Neidhart edited comment on COLLECTIONS-366 at 3/8/13 9:47 AM:
---------------------------------------------------------------------

Just to be clear on that, we need to be sure that we are not mixing up here 
with a mathematical range definition and a list containing integers in a 
certain range.

After some thoughts, I am now in favor of rejecting other numbers than int, as 
this would be the same behavior as for an List<Integer>. E.g. creating a list 
of integers in the range of 0 to 10 and calling list.contains(1.2) returns 
false, so in order for a range list to be a replacement (see Liskov 
substitution principle) for an integer list we should make sure the behavior is 
the same.
                
      was (Author: tn):
    Just to be clear on that, we are mixing up here with a mathematical range 
definition and a list containing integers in a certain range.

According to the logic above, the operation range(0, 2).contains(1.5) should 
return true, but is this really correct?
In fact the floating point number 1.5 is *not* contained in the list, you can 
easily check this when you iterate over its elements.
Also what shall be returned by indexOf(1.5)? The closest integer number?

Actually, I am now more in favor of rejecting other numbers that do not 
correspond exactly to the int numbers contained in the range, as this would be 
the same behavior as for an List<Integer>. E.g. creating a list of integers in 
the range of 0 to 10 and calling list.contains(1.2) returns false, so in order 
for a range list to be a replacement (see Liskov substitution principle) for an 
integer list we should make sure the behavior is the same.
                  
> A light-weight list of integers
> -------------------------------
>
>                 Key: COLLECTIONS-366
>                 URL: https://issues.apache.org/jira/browse/COLLECTIONS-366
>             Project: Commons Collections
>          Issue Type: New Feature
>    Affects Versions: 3.2
>            Reporter: Dmitry Katsubo
>             Fix For: 4.x
>
>         Attachments: COLLECTIONS-366.patch, RangeList_fixed1.zip
>
>
> Sometimes there is a demand too have a list, that represents numbers within 
> some range (say, [5..10]). If the range is big (millions of records), 
> creating a dummy list that holds all instances of objects is too expensive.
> The provided implementation (attached to this issue) solves this problem. 
> Nice to have in commons collections.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to