Gothic II [LeGo] Listy 4804 8

O temacie

Autor Siemekk

Zaczęty 27.01.2017 roku

Wyświetleń 4804

Odpowiedzi 8

Siemekk

Siemekk

Złote Wrota
posty2143
Propsy1154
ProfesjaProgramista
  • Złote Wrota
Tak jak w temacie chciałbym nauczyć się tworzyć Listy z LeGo.
Podstawowe pytania:
1) Do czego się ich używa?
2) Jak wygląda ich struktura?
3) Jak dodawać, usuwać i zarządzać listami?
Od razu mówię, że zapoznałem się z  tym, ogarniam co tam jest i te skróty, ale nie mam żadnego przykładu jak się to dzierży.
(Nie ma żadnych przykładów z zakładce 'Beispiele'.
 

P.S A Splash w szafie i nie ma psychy by mi dać bana.

Lehona

Lehona

Użytkownicy
posty196
Propsy190
  • Użytkownicy
They're literally just lists of integers.
1) You use them to store integers, duh. They're usually used over arrays when you want guaranteed O(1) (that means constant time) insert/remove complexity. Inserting/Removing out of the middle is or beginning is very fast.
2) Not quite sure what you mean, but you don't have to know, that's what abstractions are for (List.d in this case).
3) Google translates this to "how to add, remove and manage bills", no idea what bills mean in this case.
To add a value, use List_Add, to remove a value, use List_Delete. "Managing something" does not mean anything.

http://lego.worldofplayers.de/?List shows all available function with a short explanation (even though it's in German only... Everyone is welcome to write an English or Polish documentation...).
 
Unless specified otherwise, my posts are always about Gothic 2 Night of the Raven.

Bogdan Zwei

Bogdan Zwei

Użytkownicy
Wulgarny skurwiel pierdolony.
posty1864
Propsy541
Profesjabrak
  • Użytkownicy
  • Wulgarny skurwiel pierdolony.

Bogdan Zwei

Gothic II [LeGo] Listy
#2 2017-01-27, 20:45(Ostatnia zmiana: 2017-01-27, 21:04)
@Lehona 3 is "How to add, delete and manipulate Lists?"

@Siemekk List. Nie Letter. Zamień to, bo "list" to nazwa angielska, w tym przypadku. Lehona ma utrudnione zadanie przez takie zamiany, bo nie wie, o co Ci chodzi.
 
:ok: zachęca do dalszej pomocy. Nie zapominaj o tym!

Prywatne wiadomości typu "Ej, pomocy" kasuję od razu. Od tego jest forum, a nie PW.

To me, defeat in anything is merely temporary, and its punishment is but an urge for me to greater effort to achieve my goal. Defeat simply tells me that something is wrong in my doing; it is a path leading to success and truth.

In order to realize our true self we must be willing to live without being dependent upon the opinion of others.

Lehona

Lehona

Użytkownicy
posty196
Propsy190
  • Użytkownicy
If you want to add two lists, use List_Concat, use List_Add to append a single value to a list.

Basically everything available is at the wiki link I gave one post above.

You could also do it "manually", but unless something is impossible to do with only the lego scripts (which I find quite unlikely), I'd advise against doing so.

There's also List_InsertSorted(list, value, comparator) which is not in the official documentation yet (apparently...), I guess I'll add it after this post. Could be useful for your messaging system (maintain a list of messages that is ordered by their lifetime? Unless they all live for the same time...).
 
Unless specified otherwise, my posts are always about Gothic 2 Night of the Raven.

Siemekk

Siemekk

Złote Wrota
posty2143
Propsy1154
ProfesjaProgramista
  • Złote Wrota
3. Bogdan have right.
And trying make "Message Manager", Mark told me this: "Use Letter from Lego," but this is the problem - I can not! This is @ Mark56 Post:
Cytuj
Use the letter from Lego. First make placeholder element to not lose handle to List.
If list have more than one element (List_HasLength) - display second element. When he was displayed delete he(List_Delete).
Topic:
http://themodders.org/index.php?topic=26541.0
 

P.S A Splash w szafie i nie ma psychy by mi dać bana.

Siemekk

Siemekk

Złote Wrota
posty2143
Propsy1154
ProfesjaProgramista
  • Złote Wrota
List from LeGo offers similar functions what library <List> ? (Push_Back, Push_Front etc.)
 

P.S A Splash w szafie i nie ma psychy by mi dać bana.

Lehona

Lehona

Użytkownicy
posty196
Propsy190
  • Użytkownicy
List_Add() should be equivalent to Push_Back. There's no such thing as Push_Front yet, but I just made one (untested):
func int List_AddFront(var int list, var int data) {
if(!list) {
        _List_ErrPtr("AddFront");
        return;
    };
    var zCList l; l = _^(list);
var int next; next = l.next;
   
l.next = create(zCList@);
var zCList ln; ln = _^(l.next);
ln.next = next;

ln.data = l.data;
l.data = data;
};
 
Unless specified otherwise, my posts are always about Gothic 2 Night of the Raven.

Siemekk

Siemekk

Złote Wrota
posty2143
Propsy1154
ProfesjaProgramista
  • Złote Wrota
If i don't maked mistake List_PushBack must look like this:
/*
AST C++
void zCList<T>::InsertEnd(T* obj)
{
zCList<T>* lst = new zCList<T>;
lst->m_pData = obj;
zCList<T>* l = this;
while(l->m_pNext)
l = l->m_pNext;
l->m_pNext = lst;
}
*/

func void List_PushBack(var int list, var int data)
{
if(!list)
{
return;
};
var zCList l; l = _^(list);
var zCList lst; lst = create(zCList@);
lst.data = data;

while(l.next);
l = l.next;
end;
l.next = lst;
};
 

P.S A Splash w szafie i nie ma psychy by mi dać bana.

Lehona

Lehona

Użytkownicy
posty196
Propsy190
  • Użytkownicy
That won't compile (missing a _^()), but I literally just said that it's equivalent to List_Add(). Why write your own if List_Add() exists?

Your code is fine otherwise, but it's like 99% the same as List_Add().
 
Unless specified otherwise, my posts are always about Gothic 2 Night of the Raven.


0 użytkowników i 1 Gość przegląda ten wątek.
0 użytkowników
Do góry