
Untitled
By: a guest on
Apr 29th, 2012 | syntax:
C++ | size: 0.56 KB | hits: 16 | expires: Never
//Rikiuoja sarasa burbuliuko metodu, reikia <= operatoriaus
template <typename TDUOM,typename TPRAKTAS>
void Sarasas<TDUOM,TPRAKTAS>::Rikiuoti()
{
if (n < 2) //ar yra ka rykiuot
return;
bool bk = true;
while (bk)
{
bk = false;
Mazgas<TDUOM> *s1 = s;
Mazgas<TDUOM> *s2 = s->GautiSek();
for (int x=1; x<n ;x++, s1=s2, s2=s2->GautiSek())
if (*s2->GautiDuom() <= *s1->GautiDuom())
{
TDUOM *elem = s1->GautiDuom();
s1->KeistiDuomAdr(s2->GautiDuom());
s2->KeistiDuomAdr(elem);
bk = true;
}
}
}