Jump to content
Software FX Community

Remove a StudyGroup


MDS
 Share

Recommended Posts

I don;t think I understand your question. Do you mean to remove a study group after it is added? If so, Study Groups are simply macros that represent a group of studies. There is no API to remove all items that belong to a specific group. There is no API to obtain the studies that belong to a specific group, however, these groups are constant (they always contain the same studies) so you can easily write a program that by adding a study group to an empty studies collection can then determine what studies were added. You can store this information for later use.

Link to comment
Share on other sites

You have it correct.

So now I have a statistics object with a collection of studies.  Some were added to the statistics studies collection as individual Analysis enumerations and some were added as StudyGroup objects.  The overload of the Studies.Add method enables the addition of Analysis, Study, and StudyGroup objects.  However, there is no corresponding Remove overload.

There is, however, a Remove method which takes a Study object.  The trick, then, is to somehow convert an Analysis enumeration value into a Study.  I noticed that an Analysis value cannot be converted into a Study object (which seems strange since the StudiesCollection overload accepts an Analysis object).

 The question, then, is... must I use the Find method and then test for null?  This seems extremely inefficient way of doing things.

 One recommendation for future versions on Collection classes:  The overloads on your Add method should match the overloads on your Remove method.

Link to comment
Share on other sites

Try this.

 Create a chart with statistics.  Add a CentralTendencyMean study group programmatically.  Add a CentralTendencyMedian study group programmatically.  Now programmatically remove the CentralTendencyMedian study group analyses (and the CentralTendencyMedian custom study).

 The only way I found to do this is by using the StudiesCollection.Find method and test for null.  If it is not null, then call the StudiesCollection remove method.  However, this method results in an orphaned Range analysis in the CentralMedian custom study because both the Study groups above contain the range analysis.  There's no way to specify which Range analysis to remove (CentralTendencyMean or CentralTendencyMedian).

Very frustrating API.

Link to comment
Share on other sites

This API was not designed with studies beign removed and added interactivelly as you seem to be doing in your application. We saw the studies as something that you setup at the beginning.

Looking at this scenario, I agree that indeed the API is not good for this.

I will take in your suggestions for a future version.

What I suggest you do in this case is this:

Keep a a structure with the beginning and ending index of each study group. Every time you add or remove a study, update this list to match the location of each study group as follows:

1) When you add a group:

beginningIndex = studies.Count;

studies.Add(group);

endingIndex = studies.Count - 1;

2) When you remove a group:

- Locate group in your list of indexes (I would use a Dictionary with the Group Id as the key)

- UseRemoveAt to remove all alementes from beginningIndex to endingIndex

- Update your indexes (those after the group just removed) by substracting the group size.

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...