Proposals:Refactoring Statistics Framework 2007 Iterators: Difference between revisions

From KitwarePublic
Jump to navigationJump to search
 
(13 intermediate revisions by the same user not shown)
Line 66: Line 66:


This table indicates the level of compliance of the refactored classes comply with the checklist of iterators API defined above
This table indicates the level of compliance of the refactored classes comply with the checklist of iterators API defined above
The symbols in the table represent
* X : Implemented and Tested
* NA : Not applicable
* ? : Wondering if we really need it


{| border="1"
{| border="1"
|- bgcolor="#abcdef"
|- bgcolor="#abcdef" align="center"
! Iterator API !! ListSample !! Histogram !! Subsample !! MembershipSample  
! Iterator API !! ListSample !! Histogram !! Subsample !! MembershipSample  
|-
|-
| colspan="5" | '''ConstIterator'''
| colspan="5" | '''ConstIterator'''
|-
|-
| Default Constructor ||   ||  X  ||   ||
| Default Constructor must be protected and not implemented || ||  X  || ||
|-
|-
| Constructor with Const container argument ||   ||  X  ||   ||
| Constructor with Const container argument || ||  X  || ||
|-
|-
| Constructor with initial Id and Const container argument ||   ||  X  ||   ||
| Constructor with initial Id and Const container argument || NA ||  X? || NA ||
|-
|-
| Copy constructor(ConstIterator argument)  ||   ||  X  ||   ||
| Copy constructor(ConstIterator argument)  || ||  X  || ||
|-
|-
| operator= (ConstIterator argument)  ||   ||   ||   ||
| operator= (ConstIterator argument)  || || || ||
|-
|-
| operator==  ||   ||   ||   ||
| operator==  || || || ||
|-
|-
| operator!=  ||   ||   ||   ||
| operator!=  || || || ||
|-
|-
| operator++ (pre-increment)  ||   ||   ||   ||
| operator++ (pre-increment)  || || || ||
|-
|-
| GetFrequency()  ||   ||   ||   ||
| GetFrequency()  || || || ||
|-
|-
| GetMeasurementVector()  ||   ||   ||   ||
| GetMeasurementVector()  || || || ||
|-
|-
| GetInstanceIdentifier()  ||   ||   ||   ||
| GetInstanceIdentifier()  || || || ||
|-
|-
| colspan="5" | '''non-Const Iterator'''
| colspan="5" | '''non-Const Iterator'''
|-
|-
| Iterator must derive from ConstIterator ||   ||   ||   ||
| Iterator must derive from ConstIterator || || || ||
|-
|-
| Default Constructor ||   ||   ||   ||
| Default Constructor must be protected || || || ||
|-
|-
| Constructor with non-const container ||   ||   ||   ||
| Constructor with non-const container || || || ||
|-
|-
| Constructor with initial Id and non-const container ||   ||   ||   ||
| Constructor with initial Id and non-const container || NA || X?  || NA  ||
|-
|-
| SetFrequency() ||   ||   ||   ||
| Constructor with Const container must be protected || || || ||
|-
|-
| SetMeasurementVector() ||   ||   ||   ||
| Constructor with initial Id and Const container must be protected || NA ||  X  ||  X  ||
|-
| Copy constructor(ConstIterator argument) must be protected  ||  X  ||  X  ||  X  ||
|-
| operator= (ConstIterator argument) must be protected ||  X  ||  X  ||  X  ||
|-
| Copy constructor(Iterator argument) must be public  ||  X  ||  X  ||  X  ||
|-
| operator= (Iterator argument) must be public ||  X  ||  X  ||  X  ||
|-
| SetFrequency() ||  NA  ||  X  ||  NA  ||
|-
| SetMeasurementVector() || NA  || NA  || NA  ||
|}
|}



Latest revision as of 19:33, 17 April 2007

Review of Iterators from the Statistics Framework

Summary Table

The ITK Statistics Framework has a collection of data containers many of which have Iterators associated with them.

This page presents a review of issues that have been identified with some iterators in the Statistics Framework and describes proposed actions intended to fix those issues.

List of Issues

  • Decrement operator was not implemented correctly in itkListSample.h (Fixed)
  • Testing coverage of iterators is not complete, allowing problems like the one above to go unnoticed.
  • Functionality was not available to create (or assign) a const iterator from a non-const iterator in itkSubsample.h (Fixed). This problem was found in a number of classes (Not yet fixed).
  • In general a consistent set of iterator operations is not present.
  • MembershipSample iterator does not allow for nested subsamples.

Proposed Solutions

  • Propose a set of core iterator functionality for sample containers.
  • Update containers to include this core functionality where necessary.
  • Write tests that cover all iterator operations.
  • Fix iterator implementation bugs as uncovered by tests.

Timetable

This task is straightforward and does not require a large amount of effort. Planned completion: Monday 9 April.

List of Sample containers with iterators

  • ListSample
  • ImageToListAdaptor
  • PointSetToListAdaptor
  • Histogram
  • MembershipSample
  • Subsample
  • VariableDimensionHistogram

Common iterator interface for Sample containers

[Under construction]

In the statistics library algorithms are intended to be used for any type of sample. This generality is provided by templating algorithms over the sample type. Therefore, it is important to define a common interface for sample iterators.

Iterators API CheckList

  • ConstIterator
  • Const Iterator API
    • Constructor with Const container argument
    • Copy constructor(ConstIterator argument)
    • Copy constructor(Iterator argument)
    • operator= (ConstIterator argument)
    • operator= (Iterator argument)
    • operator==
    • operator!=
    • operator++ (pre-increment)
    • GetFrequency()
    • GetMeasurementVector()
    • GetInstanceIdentifier()
  • Iterator API
    • Iterator must derive from ConstIterator
    • Constructor with non-const container
    • SetFrequency()
    • SetMeasurementVector()

Compliance verification table

This table indicates the level of compliance of the refactored classes comply with the checklist of iterators API defined above


The symbols in the table represent

  • X : Implemented and Tested
  • NA : Not applicable
  • ? : Wondering if we really need it
Iterator API ListSample Histogram Subsample MembershipSample
ConstIterator
Default Constructor must be protected and not implemented X X X
Constructor with Const container argument X X X
Constructor with initial Id and Const container argument NA X? NA
Copy constructor(ConstIterator argument) X X X
operator= (ConstIterator argument) X X X
operator== X X X
operator!= X X X
operator++ (pre-increment) X X X
GetFrequency() X X X
GetMeasurementVector() X X X
GetInstanceIdentifier() X X X
non-Const Iterator
Iterator must derive from ConstIterator X X X
Default Constructor must be protected X X X
Constructor with non-const container X X X
Constructor with initial Id and non-const container NA X? NA
Constructor with Const container must be protected X X X
Constructor with initial Id and Const container must be protected NA X X
Copy constructor(ConstIterator argument) must be protected X X X
operator= (ConstIterator argument) must be protected X X X
Copy constructor(Iterator argument) must be public X X X
operator= (Iterator argument) must be public X X X
SetFrequency() NA X NA
SetMeasurementVector() NA NA NA

All Sample containers

SampleType:

  • ConstIterator Begin() const
  • ConstIterator End() const

SampleType::ConstIterator

  • ConstIterator()
  • ConstIterator(const ConstIterator& rhs)
  • FrequencyType GetFrequency() const
  • const MeasurementVector& GetMeasurementVector() const
  • InstanceIdentifier GetInstanceIdentifier() const
  • ConstIterator& operator++()
  • bool operator==(const ConstIterator& rhs)
  • bool operator!=(const ConstIterator& rhs)
  • ConstIterator operator=(const ConstIterator& rhs)