Skip to content

Commit d33c3ef

Browse files
authored
Trees (#20)
* Logs - Added Array based Circular Queues * Commit Logs - Enabled heaps - Array based heap support enabled - Heap operations such as Heapify and delete max tested - Heap Sort tested * Tested heap insert and heap delete root operations * Added #define Flags for Data Structures * Logs - Added Array based Circular Queues * Added generic print for queue * Commit Logs - Enabled heaps - Array based heap support enabled - Heap operations such as Heapify and delete max tested - Heap Sort tested * Tested heap insert and heap delete root operations * Added #define Flags for Data Structures * Added generic print for heaps and bug fix of heap ptr not being set * Added Binary search trees Tested create, destroy, insert, find, min, max and print routines for BST * Commit Logs - Fixed delete node routine - Added inorder and preorder node traversing * AVL Trees insert * Commit Logs - Added AVL Delete function - Fptr made generic - cosmetics * Commit logs - Added height of tree - print tree is now level based - cosmetics * Commit Logs - post order tree traverasal added - stack peek added * q peek added and fn gent ptrs added * changed to genric fn ptrs * Cosmetic changes for Trees to enable Doxygen * Squashed commit of the following: commit cdbb119 Author: Meraj <[email protected]> Date: Fri Jul 2 23:53:56 2021 +0530 Heaps (#19) * Logs - Added Array based Circular Queues * Commit Logs - Enabled heaps - Array based heap support enabled - Heap operations such as Heapify and delete max tested - Heap Sort tested * Tested heap insert and heap delete root operations * Added #define Flags for Data Structures * Logs - Added Array based Circular Queues * Added generic print for queue * Commit Logs - Enabled heaps - Array based heap support enabled - Heap operations such as Heapify and delete max tested - Heap Sort tested * Tested heap insert and heap delete root operations * Added #define Flags for Data Structures * Added generic print for heaps and bug fix of heap ptr not being set * q peek added and fn gent ptrs added * changed to genric fn ptrs * Cosmetic changes for Heaps to enable Doxygen * Squashed commit of the following: commit f4377ef Author: Meraj <[email protected]> Date: Fri Jul 2 01:11:53 2021 +0530 Update README.md Build and run commands commit 93ce3e7 Author: Meraj <[email protected]> Date: Fri Jul 2 01:02:16 2021 +0530 Queues (#17) * Logs - Added Array based Circular Queues * Logs - Added Array based Circular Queues * Added generic print for queue * q peek added and fn gent ptrs added * Squashed commit of the following: commit 151df29 Author: BlindCentaur <[email protected]> Date: Mon Jun 14 23:15:53 2021 +0530 Added functions for Link list based stacks commit aa327c3 Merge: 640429c 9a3759b Author: BlindCentaur <[email protected]> Date: Mon Jun 14 21:48:11 2021 +0530 Merge branch 'link_list' into stacks commit 9a3759b Author: jar3m <[email protected]> Date: Mon Jun 14 21:38:25 2021 +0530 moved destroy to end commit de18fc1 Author: BlindCentaur <[email protected]> Date: Sat Jun 12 01:03:29 2021 +0530 rectified del_idx and added tests, WIP: Circular count is incorrect commit d5adfab Author: jar3m <[email protected]> Date: Wed Jun 9 10:48:21 2021 +0530 added function ptr for destroy and print in linklist commit 12990f5 Author: BlindCentaur <[email protected]> Date: Tue Jun 8 22:41:14 2021 +0530 print for XOR LL and fixed compilation issues commit a8da18d Author: BlindCentaur <[email protected]> Date: Thu Jun 3 23:55:01 2021 +0530 fixed xor ll delete commit 5f393cc Author: BlindCentaur <[email protected]> Date: Mon May 31 16:12:24 2021 +0530 WIP : Added index delete and xor based linked list commit 8fd459a Author: jar3m <[email protected]> Date: Sun May 30 15:40:30 2021 +0530 Generic ptr compare added to link list commit e80c089 Author: jar3m <[email protected]> Date: Fri May 21 19:19:53 2021 +0530 cosmetics * Cosmetic changes for Queues to enable Doxygen * Enabled link list based queue * Added Doxygen for queues Co-authored-by: BlindCentaur <[email protected]> Co-authored-by: jar3m <[email protected]> commit a334403 Merge: a7e5b0d 8921cbc Author: jar3m <[email protected]> Date: Thu Jul 1 23:34:08 2021 +0530 Merge branch 'stacks' commit 8921cbc Merge: 071f86a a7e5b0d Author: jar3m <[email protected]> Date: Thu Jul 1 23:33:24 2021 +0530 Merge branch 'master' into stacks commit 071f86a Author: jar3m <[email protected]> Date: Thu Jul 1 00:11:53 2021 +0530 Enabled Doxygen commit 33269f9 Author: jar3m <[email protected]> Date: Wed Jun 30 23:56:50 2021 +0530 Cosmetics and Merge Master commit a7e5b0d Author: Meraj <[email protected]> Date: Wed Jun 30 23:27:37 2021 +0530 Link List & Common Libs (#15) * Configuring build for link -list * Added struct def to linklist * Commit Logs - Added backtrace on coredump - changed declaration of del_mem to free_mem - added/cleaned up link_list struct and function def * Create/destroy Link List api' * Defs.make updated to select tuning params * moved t_elem datatype to common * Added get_node and added rule for stacks * Add end fn (append) defined for SLL,DLL,SCLL,DCLL * added add_begin functions for SLL,DLL,SCLL,DCLL * Stack structure definition * stack source file created * added full, empty and size fn declartions to stacks * adding delete functions to link list * Stack structure definition * stack source file created * added full, empty and size fn declartions to stacks * updated stack structure * - Cosmetic changes: Added Function headers and comments - Bug fixed in Add begin tail ptr not being updated - Tail & Head ptr not set to NULL in after del resulting in empty list causing corruption of data on reusing the list * COMMIT DETAILS - Enabled Generic support for link list - Added generic_def.h/c as helper functions for data type generic lists - Added Comments - Test file updated to show link list of diff types such as char, int, float and string - All link list operations are now data type independent * Commit Logs - Fixed bug in delete in SLL * Moved free fn ptr defn to typedefs.h * Added generic print for data * changed generic fn routines * cosmetics * Generic ptr compare added to link list * WIP : Added index delete and xor based linked list * fixed xor ll delete * print for XOR LL and fixed compilation issues * added function ptr for destroy and print in linklist * rectified del_idx and added tests, WIP: Circular count is incorrect * moved destroy to end * Commit Logs - Added new struct to be passed along create that populates data type spefic fn ptrs required for maintaining data struct - two different links for just printing the data and the other for getting detailed info of linklist inlcuding count , addresses and links * Commit Logs - Added generic fn ptrs - Defined get head, tail, end, next and prv fn ptrs in ll struct implementation to be done - defined get and find node struct in ll - fn names changed and cosmetic changes * * defined api's for ll head, tail, end, prev and next * changed destroy and print api's using head, end and next ll routines * TODO implement the above 2 points for xor link list * cosmetics funtion headers and indentations * Added get next and prev for xor ll. works only when iterating from start to end o f list not otherwise Del node and del i th node in xor ll need to be debugged * added find function for linked list * added get ith node function in the linked list * Cosmetic changes for Doxygen support - Added function headers - Added Structure feild descriptions - Added File headers - Added Macro and Enums description comments * Added util api for printing link_list type * Del node xor list fixed * cosmetics * added delete index for xor link list * Test link list clean up * Added Link list get data routine Co-authored-by: BlindCentaur <[email protected]> commit 6c911e5 Author: jar3m <[email protected]> Date: Tue Jun 29 22:10:41 2021 +0530 Stack Cleanup & Cosmetics commit 7320cf3 Author: jar3m <[email protected]> Date: Tue Jun 29 21:23:18 2021 +0530 Squashed commit of the following: commit 5cfadc0 Author: BlindCentaur <[email protected]> Date: Sun Jun 27 20:59:00 2021 +0530 added delete index for xor link list commit c3f0fa8 Author: jar3m <[email protected]> Date: Sun Jun 27 19:47:11 2021 +0530 cosmetics commit db91b61 Author: jar3m <[email protected]> Date: Sun Jun 27 19:35:55 2021 +0530 Del node xor list fixed commit 14e1fa6 Author: jar3m <[email protected]> Date: Sat Jun 26 00:35:56 2021 +0530 Added util api for printing link_list type commit c8d0022 Author: jar3m <[email protected]> Date: Fri Jun 25 01:18:01 2021 +0530 Cosmetic changes for Doxygen support - Added function headers - Added Structure feild descriptions - Added File headers - Added Macro and Enums description comments commit 0902742 Author: kamalakannan-s <[email protected]> Date: Thu Jun 24 00:34:30 2021 -0700 added get ith node function in the linked list commit c3001d0 Author: kamalakannan-s <[email protected]> Date: Wed Jun 23 23:58:07 2021 -0700 added find function for linked list commit 0dffa25 Author: jar3m <[email protected]> Date: Thu Jun 24 01:22:25 2021 +0530 Added get next and prev for xor ll. works only when iterating from start to end o f list not otherwise Del node and del i th node in xor ll need to be debugged commit 7360706 Author: jar3m <[email protected]> Date: Wed Jun 23 01:01:09 2021 +0530 * defined api's for ll head, tail, end, prev and next * changed destroy and print api's using head, end and next ll routines * TODO implement the above 2 points for xor link list * cosmetics funtion headers and indentations commit 4a0f4f3 Author: jar3m <[email protected]> Date: Sun Jun 20 23:02:16 2021 +0530 Commit Logs - Added generic fn ptrs - Defined get head, tail, end, next and prv fn ptrs in ll struct implementation to be done - defined get and find node struct in ll - fn names changed and cosmetic changes commit 8ebd61f Author: jar3m <[email protected]> Date: Sun Jun 20 12:54:47 2021 +0530 Commit Logs - Added new struct to be passed along create that populates data type spefic fn ptrs required for maintaining data struct - two different links for just printing the data and the other for getting detailed info of linklist inlcuding count , addresses and links commit 4519c94 Author: jar3m <[email protected]> Date: Sat Jun 26 22:36:22 2021 +0530 Changed routine name commit f3b5339 Author: jar3m <[email protected]> Date: Sat Jun 26 00:37:41 2021 +0530 cosmetics indentation commit ee10cdb Author: jar3m <[email protected]> Date: Sat Jun 26 00:27:53 2021 +0530 Cosmetic changes for Stacks to enable Doxygen commit 151df29 Author: BlindCentaur <[email protected]> Date: Mon Jun 14 23:15:53 2021 +0530 Added functions for Link list based stacks commit aa327c3 Merge: 640429c 9a3759b Author: BlindCentaur <[email protected]> Date: Mon Jun 14 21:48:11 2021 +0530 Merge branch 'link_list' into stacks commit 9a3759b Author: jar3m <[email protected]> Date: Mon Jun 14 21:38:25 2021 +0530 moved destroy to end commit de18fc1 Author: BlindCentaur <[email protected]> Date: Sat Jun 12 01:03:29 2021 +0530 rectified del_idx and added tests, WIP: Circular count is incorrect commit d5adfab Author: jar3m <[email protected]> Date: Wed Jun 9 10:48:21 2021 +0530 added function ptr for destroy and print in linklist commit 12990f5 Author: BlindCentaur <[email protected]> Date: Tue Jun 8 22:41:14 2021 +0530 print for XOR LL and fixed compilation issues commit a8da18d Author: BlindCentaur <[email protected]> Date: Thu Jun 3 23:55:01 2021 +0530 fixed xor ll delete commit 5f393cc Author: BlindCentaur <[email protected]> Date: Mon May 31 16:12:24 2021 +0530 WIP : Added index delete and xor based linked list commit 8fd459a Author: jar3m <[email protected]> Date: Sun May 30 15:40:30 2021 +0530 Generic ptr compare added to link list commit e80c089 Author: jar3m <[email protected]> Date: Fri May 21 19:19:53 2021 +0530 cosmetics Co-authored-by: Harshadeva P <[email protected]> commit f4377ef Author: Meraj <[email protected]> Date: Fri Jul 2 01:11:53 2021 +0530 Update README.md Build and run commands commit 93ce3e7 Author: Meraj <[email protected]> Date: Fri Jul 2 01:02:16 2021 +0530 Queues (#17) * Logs - Added Array based Circular Queues * Logs - Added Array based Circular Queues * Added generic print for queue * q peek added and fn gent ptrs added * Squashed commit of the following: commit 151df29 Author: BlindCentaur <[email protected]> Date: Mon Jun 14 23:15:53 2021 +0530 Added functions for Link list based stacks commit aa327c3 Merge: 640429c 9a3759b Author: BlindCentaur <[email protected]> Date: Mon Jun 14 21:48:11 2021 +0530 Merge branch 'link_list' into stacks commit 9a3759b Author: jar3m <[email protected]> Date: Mon Jun 14 21:38:25 2021 +0530 moved destroy to end commit de18fc1 Author: BlindCentaur <[email protected]> Date: Sat Jun 12 01:03:29 2021 +0530 rectified del_idx and added tests, WIP: Circular count is incorrect commit d5adfab Author: jar3m <[email protected]> Date: Wed Jun 9 10:48:21 2021 +0530 added function ptr for destroy and print in linklist commit 12990f5 Author: BlindCentaur <[email protected]> Date: Tue Jun 8 22:41:14 2021 +0530 print for XOR LL and fixed compilation issues commit a8da18d Author: BlindCentaur <[email protected]> Date: Thu Jun 3 23:55:01 2021 +0530 fixed xor ll delete commit 5f393cc Author: BlindCentaur <[email protected]> Date: Mon May 31 16:12:24 2021 +0530 WIP : Added index delete and xor based linked list commit 8fd459a Author: jar3m <[email protected]> Date: Sun May 30 15:40:30 2021 +0530 Generic ptr compare added to link list commit e80c089 Author: jar3m <[email protected]> Date: Fri May 21 19:19:53 2021 +0530 cosmetics * Cosmetic changes for Queues to enable Doxygen * Enabled link list based queue * Added Doxygen for queues Co-authored-by: BlindCentaur <[email protected]> Co-authored-by: jar3m <[email protected]> commit a334403 Merge: a7e5b0d 8921cbc Author: jar3m <[email protected]> Date: Thu Jul 1 23:34:08 2021 +0530 Merge branch 'stacks' commit 8921cbc Merge: 071f86a a7e5b0d Author: jar3m <[email protected]> Date: Thu Jul 1 23:33:24 2021 +0530 Merge branch 'master' into stacks commit 071f86a Author: jar3m <[email protected]> Date: Thu Jul 1 00:11:53 2021 +0530 Enabled Doxygen commit 33269f9 Author: jar3m <[email protected]> Date: Wed Jun 30 23:56:50 2021 +0530 Cosmetics and Merge Master commit a7e5b0d Author: Meraj <[email protected]> Date: Wed Jun 30 23:27:37 2021 +0530 Link List & Common Libs (#15) * Configuring build for link -list * Added struct def to linklist * Commit Logs - Added backtrace on coredump - changed declaration of del_mem to free_mem - added/cleaned up link_list struct and function def * Create/destroy Link List api' * Defs.make updated to select tuning params * moved t_elem datatype to common * Added get_node and added rule for stacks * Add end fn (append) defined for SLL,DLL,SCLL,DCLL * added add_begin functions for SLL,DLL,SCLL,DCLL * Stack structure definition * stack source file created * added full, empty and size fn declartions to stacks * adding delete functions to link list * Stack structure definition * stack source file created * added full, empty and size fn declartions to stacks * updated stack structure * - Cosmetic changes: Added Function headers and comments - Bug fixed in Add begin tail ptr not being updated - Tail & Head ptr not set to NULL in after del resulting in empty list causing corruption of data on reusing the list * COMMIT DETAILS - Enabled Generic support for link list - Added generic_def.h/c as helper functions for data type generic lists - Added Comments - Test file updated to show link list of diff types such as char, int, float and string - All link list operations are now data type independent * Commit Logs - Fixed bug in delete in SLL * Moved free fn ptr defn to typedefs.h * Added generic print for data * changed generic fn routines * cosmetics * Generic ptr compare added to link list * WIP : Added index delete and xor based linked list * fixed xor ll delete * print for XOR LL and fixed compilation issues * added function ptr for destroy and print in linklist * rectified del_idx and added tests, WIP: Circular count is incorrect * moved destroy to end * Commit Logs - Added new struct to be passed along create that populates data type spefic fn ptrs required for maintaining data struct - two different links for just printing the data and the other for getting detailed info of linklist inlcuding count , addresses and links * Commit Logs - Added generic fn ptrs - Defined get head, tail, end, next and prv fn ptrs in ll struct implementation to be done - defined get and find node struct in ll - fn names changed and cosmetic changes * * defined api's for ll head, tail, end, prev and next * changed destroy and print api's using head, end and next ll routines * TODO implement the above 2 points for xor link list * cosmetics funtion headers and indentations * Added get next and prev for xor ll. works only when iterating from start to end o f list not otherwise Del node and del i th node in xor ll need to be debugged * added find function for linked list * added get ith node function in the linked list * Cosmetic changes for Doxygen support - Added function headers - Added Structure feild descriptions - Added File headers - Added Macro and Enums description comments * Added util api for printing link_list type * Del node xor list fixed * cosmetics * added delete index for xor link list * Test link list clean up * Added Link list get data routine Co-authored-by: BlindCentaur <[email protected]> commit 6c911e5 Author: jar3m <[email protected]> Date: Tue Jun 29 22:10:41 2021 +0530 Stack Cleanup & Cosmetics commit 7320cf3 Author: jar3m <[email protected]> Date: Tue Jun 29 21:23:18 2021 +0530 Squashed commit of the following: commit 5cfadc0 Author: BlindCentaur <[email protected]> Date: Sun Jun 27 20:59:00 2021 +0530 added delete index for xor link list commit c3f0fa8 Author: jar3m <[email protected]> Date: Sun Jun 27 19:47:11 2021 +0530 cosmetics commit db91b61 Author: jar3m <[email protected]> Date: Sun Jun 27 19:35:55 2021 +0530 Del node xor list fixed commit 14e1fa6 Author: jar3m <[email protected]> Date: Sat Jun 26 00:35:56 2021 +0530 Added util api for printing link_list type commit c8d0022 Author: jar3m <[email protected]> Date: Fri Jun 25 01:18:01 2021 +0530 Cosmetic changes for Doxygen support - Added function headers - Added Structure feild descriptions - Added File headers - Added Macro and Enums description comments commit 0902742 Author: kamalakannan-s <[email protected]> Date: Thu Jun 24 00:34:30 2021 -0700 added get ith node function in the linked list commit c3001d0 Author: kamalakannan-s <[email protected]> Date: Wed Jun 23 23:58:07 2021 -0700 added find function for linked list commit 0dffa25 Author: jar3m <[email protected]> Date: Thu Jun 24 01:22:25 2021 +0530 Added get next and prev for xor ll. works only when iterating from start to end o f list not otherwise Del node and del i th node in xor ll need to be debugged commit 7360706 Author: jar3m <[email protected]> Date: Wed Jun 23 01:01:09 2021 +0530 * defined api's for ll head, tail, end, prev and next * changed destroy and print api's using head, end and next ll routines * TODO implement the above 2 points for xor link list * cosmetics funtion headers and indentations commit 4a0f4f3 Author: jar3m <[email protected]> Date: Sun Jun 20 23:02:16 2021 +0530 Commit Logs - Added generic fn ptrs - Defined get head, tail, end, next and prv fn ptrs in ll struct implementation to be done - defined get and find node struct in ll - fn names changed and cosmetic changes commit 8ebd61f Author: jar3m <[email protected]> Date: Sun Jun 20 12:54:47 2021 +0530 Commit Logs - Added new struct to be passed along create that populates data type spefic fn ptrs required for maintaining data struct - two different links for just printing the data and the other for getting detailed info of linklist inlcuding count , addresses and links commit 4519c94 Author: jar3m <[email protected]> Date: Sat Jun 26 22:36:22 2021 +0530 Changed routine name commit f3b5339 Author: jar3m <[email protected]> Date: Sat Jun 26 00:37:41 2021 +0530 cosmetics indentation commit ee10cdb Author: jar3m <[email protected]> Date: Sat Jun 26 00:27:53 2021 +0530 Cosmetic changes for Stacks to enable Doxygen commit 151df29 Author: BlindCentaur <[email protected]> Date: Mon Jun 14 23:15:53 2021 +0530 Added functions for Link list based stacks commit aa327c3 Merge: 640429c 9a3759b Author: BlindCentaur <[email protected]> Date: Mon Jun 14 21:48:11 2021 +0530 Merge branch 'link_list' into stacks commit 9a3759b Author: jar3m <[email protected]> Date: Mon Jun 14 21:38:25 2021 +0530 moved destroy to end commit de18fc1 Author: BlindCentaur <[email protected]> Date: Sat Jun 12 01:03:29 2021 +0530 rectified del_idx and added tests, WIP: Circular count is incorrect commit d5adfab Author: jar3m <[email protected]> Date: Wed Jun 9 10:48:21 2021 +0530 added function ptr for destroy and print in linklist commit 12990f5 Author: BlindCentaur <[email protected]> Date: Tue Jun 8 22:41:14 2021 +0530 print for XOR LL and fixed compilation issues commit a8da18d Author: BlindCentaur <[email protected]> Date: Thu Jun 3 23:55:01 2021 +0530 fixed xor ll delete commit 5f393cc Author: BlindCentaur <[email protected]> Date: Mon May 31 16:12:24 2021 +0530 WIP : Added index delete and xor based linked list commit 8fd459a Author: jar3m <[email protected]> Date: Sun May 30 15:40:30 2021 +0530 Generic ptr compare added to link list commit e80c089 Author: jar3m <[email protected]> Date: Fri May 21 19:19:53 2021 +0530 cosmetics
1 parent cdbb119 commit d33c3ef

9 files changed

Lines changed: 1277 additions & 4 deletions

File tree

Defs.make

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,5 @@ DS_FLAGS = -DLINK_LIST=$(LINK_LIST) -DSTACK=$(STACK) \
3838
@echo "STACKS= $(STACK)"
3939
@echo "QUEUES= $(QUEUE)"
4040
@echo "HEAPS= $(HEAP)"
41-
@echo "TREES= $(TREE)"
41+
@echo "TREES= $(TREE)"
42+

ds/Makefile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ link_list_ARCHIVE=$(PROJ_PATH)/ds/link_list/link_list.o
33
stack_ARCHIVE=$(PROJ_PATH)/ds/stack/stack.o
44
queue_ARCHIVE=$(PROJ_PATH)/ds/queue/queue.o
55
heap_ARCHIVE=$(PROJ_PATH)/ds/heap/heap.o
6+
tree_ARCHIVE=$(PROJ_PATH)/ds/tree/tree.o
67

78
ds_ARCHIVE=$(PROJ_PATH)/ds/bin/ds.a
89

@@ -14,7 +15,7 @@ sub_ARCHIVE += $(link_list_ARCHIVE)
1415
endif
1516

1617
ifeq ($(STACK), true)
17-
INCLUDES += -I $(PROJ_PATH)/ds/stacks/
18+
INCLUDES += -I $(PROJ_PATH)/ds/stack/
1819
sub_ARCHIVE += $(stack_ARCHIVE)
1920
endif
2021

@@ -28,6 +29,11 @@ INCLUDES += -I $(PROJ_PATH)/ds/heap/
2829
sub_ARCHIVE += $(heap_ARCHIVE)
2930
endif
3031

32+
ifeq ($(TREE), true)
33+
INCLUDES += -I $(PROJ_PATH)/ds/tree/
34+
sub_ARCHIVE += $(tree_ARCHIVE)
35+
endif
36+
3137
all: $(ds_ARCHIVE)
3238

3339
$(ds_ARCHIVE): $(sub_ARCHIVE)
@@ -47,6 +53,9 @@ $(queue_ARCHIVE) :
4753
$(heap_ARCHIVE) :
4854
make -C heap/ all
4955

56+
$(tree_ARCHIVE) :
57+
make -C tree/ all
58+
5059
clean:
5160
rm -rf $(ds_ARCHIVE) $(sub_ARCHIVE)
5261

ds/queue/queue.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ void queue_enqueue_arr(t_gen d, t_gen data)
8787
if (q->full(q) == true) {
8888
LOG_WARN("QUEUES", "%s: Queue Full\n",q->name);
8989
}
90-
90+
9191
// queue empty (added first element)
9292
q->front = (q->front != -1) ? q->front : 0;
9393

ds/stack/stack.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ t_gen stack_peek(t_gen d,int idx)
302302
t_gen n;
303303

304304
// index out of bound
305-
if ((idx < 0) && (idx >= s->count)) {
305+
if ((idx < 0) || (idx >= s->count)) {
306306
LOG_WARN("STACKS", "index is out of bounds\n", s->count);
307307
return NULL;
308308
}
@@ -313,6 +313,7 @@ t_gen stack_peek(t_gen d,int idx)
313313
}
314314

315315
// Return data for link list based stack
316+
l = (t_linklist*)s->data;
316317
n = l->get_idx(l, idx);
317318

318319
return l->get_node_data(n);

ds/tree/Makefile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
tree_SRC=tree.c
2+
tree_OBJ=tree.o
3+
4+
OBJS=$(tree_OBJ)
5+
6+
all: $(OBJS)
7+
8+
$(tree_OBJ): $(tree_SRC)
9+
$(CC) $(INCLUDES) -c $^ -o $@ $(CFLAGS)
10+
11+
12+
.PHONY: clean
13+
14+
clean:
15+
rm -rf $(tree_ARCHIVE) $(OBJS)

0 commit comments

Comments
 (0)