עבור לתוכן

ממשק של תא ושל רשימה של משרד החינוך

Featured Replies

פורסם

יש לי כאן 2 ממשקים של משרד החינוך של תאים ושל רשימה המורכבת מתאים


{
private T info;
private Node<T> next;
public Node()
{
next = null;
}
public Node(T val)
{
info = val;
next = null;
}
public Node(T val, Node<T> next)
{
info = val;
this.next = next;
}
public T GetInfo()
{
return info;
}
public Node<T> Getnext()
{
return next;
}
public void SetInfo(T val)
{
info = val;
}
public void SetNext(Node<T> next)
{
this.next = next;
}
}
class Node<T>

------------------------------------------------------


{
private Node.Node<T> head;
private Node.Node<T> tail;
public List()
{
head = new Node.Node<T>();
tail = head;
}
public Node.Node<T> GetFirst()
{
return head.Getnext();
}
public Node.Node<T> Insert(T val, Node.Node<T> P)
{
if (P == null)
{
P = head;
}
P.SetNext(new Node.Node<T>(val, P.Getnext()));
return P.Getnext();
}
public Node.Node<T> Remove(Node.Node<T> P)
{
Node.Node<T> t;
for (t = head; t.Getnext() != P; t = t.Getnext()) ;
t.SetNext(P.Getnext());
return t.Getnext();
}
public bool IsEmpty()
{
return head.Getnext() == null;
}

}
class List<T>

אבקש הסבר של כמה שיותר פונקציות כאן

אני לא מבין את הרעיון של הרשימה הזאת

ואיך שפועלים איתה.

אני צריך גם לרשום פונקציה/יות שתמיין רשימה מהסוג הזה.

פורסם
  • מחבר

תודה על שהערת לי. שיניתי!

אני מכיר את הרשימה הרגילה בצורה מאוד שטחית.

פורסם

מה זאת אומרת "הרשימה הרגילה"?

הקוד הזה הוא פשוט מימוש של רשימה מקושרת ב-#C.

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

דיונים חדשים