Commits

samuel bustamante  committed e452d0c

Cambio de Estructura (Linked_List)

  • Participants
  • Parent commits 757ffd9

Comments (0)

Files changed (1)

File P1-Grupo13.c

 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+
 /********** Macros ***********/
 
 #define TRUE 1
     struct Node *Previous;
 } Node_P;
 
-struct Node_P *Init_List_Ordered;
+typedef struct {
+    Node_P *Init;
+    int Length;
+} Linked_List;
 
 /********* Funciones *********/
 
 void Copy_Tuples_P(Tuple_P *From, Tuple_P *To);
 
-int Locate_List_Disordered(Node_P *Init_List_Disordered, Code Code_P, Node_P *Position_Node_P);
-int Evoke_List_Disordered(Node_P *Init_List_Disordered, Code Code_P, Tuple_P *Element_P);
-int Append_List_Disordered(Node_P *Init_List_Disordered, Tuple_P *Element_P);
-int Remove_List_Disordered(Node_P *Init_List_Disordered, Code Code_P);
+int New_Node_P(Node_P *Node_P);
+int Empty_List(Linked_List *List);
+int Full_List(Linked_List *List);
 
-int Locate_List_Ordered(Node_P *Init_List_Ordered, Code Code_P, Node_P *Position_Node_P);
-int Evoke_List_Ordered(Node_P *Init_List_Ordered, Code Code_P, Tuple_P *Element_P);
-int Append_List_Ordered(Node_P *Init_List_Ordered, Tuple_P *Element_P);
-int Remove_List_Ordered(Node_P *Init_List_Ordered, Code Code_P);
+int Locate_Disordered_List(Node_P *Init_List, Code Code_P, Node_P *Position_Node_P);
+int Evoke_Disordered_List(Linked_List *List, Code Code_P, Tuple_P *Element_P);
+int Append_Disordered_List(Linked_List *List, Tuple_P *Element_P);
+int Remove_Disordered_List(Linked_List *List, Code Code_P);
+
+int Locate_Ordered_List(Node_P *Init_List, Code Code_P, Node_P *Position_Node_P);
+int Evoke_Ordered_List(Linked_List *List, Code Code_P, Tuple_P *Element_P);
+int Append_Ordered_List(Linked_List *List, Tuple_P *Element_P);
+int Remove_Ordered_List(Linked_List *List, Code Code_P);
 
 /*********** Main ************/
 
 
 /*****************************/
 
-// Ignacio
-
-int Locate_List_Disordered(Node_P *Init_List_Disordered, Code Code_P, Node_P *Position_Node_P) {
-
+int Empty_List(Linked_List *List) {
+    return List->Length == 0;
 }
 
-int Evoke_List_Disordered(Node_P *Init_List_Disordered, Code Code_P, Tuple_P *Element_P) {
-
+int Full_List(Linked_List *List) {
+    return List->Length == MAX_LIST;
 }
 
-int Append_List_Disordered(Node_P *Init_List_Disordered, Tuple_P *Element_P) {
-
-}
-
-int Remove_List_Ordered(Node_P *Init_List_Ordered, Code Code_P) {
-
-}
-
-// Samuel
-
 void Copy_Tuples_P(Tuple_P *From, Tuple_P *To) {
     strcpy(From->Code_P, To->Code_P);
     strcpy(From->Name_P, To->Name_P);
     strcpy(From->University_P, To->University_P);
 }
 
-int Locate_Ordered_List(Node_P *Init_List_Ordered, Code Code_P, Node_P *Position_Node_P) {
-    if (Init_List_Ordered->Next == NULL || Init_List_Ordered->Data.Code_P > Code_P) {
+// Ignacio
+
+int Locate_Disordered_List(Node_P *Init_List, Code Code_P, Node_P *Position_Node_P) {
+}
+
+int Evoke_Disordered_List(Linked_List *List, Code Code_P, Tuple_P *Element_P) {
+}
+
+int Append_Disordered_List(Linked_List *List, Tuple_P *Element_P) {
+}
+
+int Remove_Disordered_List(Linked_List *List, Code Code_P) {
+}
+
+// Samuel
+
+int Locate_Ordered_List(Node_P *Init_List, Code Code_P, Node_P *Position_Node_P) {
+    if (Init_List == NULL || Init_List->Data.Code_P > Code_P) {
         return FALSE;
-    } else if (Init_List_Ordered->Data.Code_P == Code_P) {
-        Position_Node_P = Init_List_Ordered;
+    } else if (Init_List->Data.Code_P == Code_P) {
+        Position_Node_P = Init_List;
         return TRUE;
     } else {
-        Locate_Ordered_List(Init_List_Ordered->Next, Code_P, Position_Node_P);
+        Locate_Ordered_List(Init_List->Next, Code_P, Position_Node_P);
     }
 }
 
-int Evoke_Ordered_List(Node_P *Init_List_Ordered, Code Code_P, Tuple_P *Element_P) {
-    Node_P *Position_Node;
-    if (Locate_Ordered_List(Init_List_Ordered, Code_P, Position_Node)) {
-        Copy_Tuples_P(&(Position_Node->Data), Element_P);
+int Evoke_Ordered_List(Linked_List *List, Code Code_P, Tuple_P *Element_P) {
+    Node_P *Position_Node_P;
+    if (Locate_Ordered_List(List->Init, Code_P, Position_Node_P)) {
+        Copy_Tuples_P(&(Position_Node_P->Data), Element_P);
         return TRUE;
     } else {
         return FALSE;
     }
 }
 
-int Append_Ordered_List(Node_P *Init_List_Ordered, Tuple_P *Element_P) {
-    Node_P *Position_Node;
-    if (Locate_Ordered_List(Init_List_Ordered, Element_P->Code_P, Position_Node)) {
+int Append_Ordered_List(Linked_List *List, Tuple_P *Element_P) {
+    Node_P *Position_Node_P;
+    if (Locate_Ordered_List(List->Init, Element_P->Code_P, Position_Node_P)) {
         
     } else {
         return FALSE;
     }
 }
 
-int Remove_Ordered_List(Node_P *Init_List_Ordered, Code Code_P) {
-    Node_P *Position_Node;
-    if (Locate_Ordered_List(Init_List_Ordered, Code_P, Position_Node)) {
-        if (Position_Node->Next != NULL)
-            *(&(Position_Node->Previous)->Next) = Position_Node->Next;
-        if (Position_Node->Previous != NULL)
-            *(&(Position_Node->Next)->Previous) = Position_Node->Next;
-        free(Position_Node);
+int Remove_Ordered_List(Linked_List *List, Code Code_P) {
+    Node_P *Position_Node_P;
+    if (Locate_Ordered_List(List->Init, Code_P, Position_Node_P)) {
+        if (Position_Node_P->Next != NULL)
+            *(&(Position_Node_P->Previous)->Next) = Position_Node_P->Next;
+        if (Position_Node_P->Previous != NULL)
+            *(&(Position_Node_P->Next)->Previous) = Position_Node_P->Next;
+        free(Position_Node_P);
     } else {
         return FALSE;
     }