[Insight-developers] type issues in itkPriorityQueueTest

Arnaud GELAS arnaud_gelas at hms.harvard.edu
Thu Jan 20 14:24:01 EST 2011


Hi Luis,

You're right, -1 was used for non-found situation, and it can be 
replaced by this constant!

I'll submit a first patch by introducing this constant, then later I'll 
submit another one (for the simplification of the update mechanism, 
still struggling to make it working with non-pointers and pointers element).

Thanks,
Arnaud

On 01/20/2011 02:13 PM, Luis Ibanez wrote:
> Hi Arnaud,
>
> Does it really make sense to use a -1
> as return code for an identifier ?
>
> It is that for an error condition ?
>
> or for indicating that an element has not been found ?
>
> If this is a non-found situation,
> then we probably should define an error code,
> such as
>
> const IdentifierType  ELEMENT_NOT_FOUND =
>     itk::NumericTraits<IdentifierType>::max();
>
> and then use this symbol for the error checking,
> such as
>
>     if( ElementId != ELEMENT_NOT_FOUND )
>      {....
>
>
> On the other hand, if this is really an error condition,
> then we should be throwing an Exception.
>
>
>    My 2 cents,
>
>
>         Luis
>
>
> --------------------------------------------------------------------------------------
> On Thu, Jan 20, 2011 at 10:38 AM, Arnaud GELAS
> <arnaud_gelas at hms.harvard.edu>  wrote:
>> Hi Luis,
>>
>> In 811aef1f, you have changed the identifier type in itkPriorityQueueTest
>> from int to itk::IdentifierType (which is an unsigned one).
>>
>> The current test which is not complete does not test the method Update(
>> element ) where one identifier is compared to -1 (line 320), so with such a
>> type the test would always fail...
>>
>> I am now right working on improving the test to test this method.
>>
>> Should we ensure ElementIdentifier to be signed with some concept checking
>> or should the comparison be done on cast version of -1 ?
>>
>> Thanks,
>> Arnaud
>>



More information about the Insight-developers mailing list