'Strategy Sequence Diagram
I am trying to create a sequence diagram and I am not sure I am doing it correct, because inside Sort function in Sorter Class has for example the strategy DownComparer that will be called more than one time. Does the Arrows from ShouldSwap and the return bool value from SortStrategy->Sorter should look like I did or it should look like something else?
public class Sorter
{
public IComparer m_Comparer { get; set; }
public Sorter(IComparer i_Comparer)
{
m_Comparer = i_Comparer;
}
public void Sort(ref ListBox i_ListBox)
{
for (int i = 0; i < i_ListBox.Items.Count - 1; i++)
{
for (int j = i + 1; j < i_ListBox.Items.Count; j++)
{
if (m_Comparer.ShouldSwap(i_ListBox.Items[i] as Group, i_ListBox.Items[j] as Group))
{
doSwap(i_ListBox.Items, i, j);
}
}
}
}
private void doSwap(ListBox.ObjectCollection i_Items, int i_Index1, int i_Index2)
{
object temp = i_Items[i_Index1];
i_Items[i_Index1] = i_Items[i_Index2];
i_Items[i_Index2] = temp;
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

