|
|
|
@ -36,15 +36,19 @@ public class SongList { |
|
|
|
m_last = to_add; |
|
|
|
m_last.setLink(m_last); |
|
|
|
} |
|
|
|
else if (m_last.getTitle().compareTo(title) <= 0) { |
|
|
|
to_add.setLink(m_last.getLink()); |
|
|
|
m_last.setLink(to_add); |
|
|
|
m_last = to_add; |
|
|
|
} |
|
|
|
else { |
|
|
|
Song current = m_last.getLink(); |
|
|
|
while ((current.getTitle().compareTo(title)) > 0 && (current.getLink() != m_last)) { |
|
|
|
// start from last song |
|
|
|
Song current = m_last; |
|
|
|
while (title.compareTo(current.getLink().getTitle()) >= 0) { |
|
|
|
current = current.getLink(); |
|
|
|
} |
|
|
|
to_add.setLink(current.getLink()); |
|
|
|
current.setLink(to_add); |
|
|
|
if (current.getTitle().compareTo(to_add.getTitle()) > 0) |
|
|
|
m_last = null; |
|
|
|
} |
|
|
|
m_numElements += 1; |
|
|
|
} |
|
|
|
|