forked from coderZsq/coderZsq.practice.native
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
110 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
StudyNotes/Foundation/Algorithm4Objective-C/Algorithm4Objective-C/Stack.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// | ||
// Stack.c | ||
// Algorithm4Objective-C | ||
// | ||
// Created by 朱双泉 on 2019/1/24. | ||
// Copyright © 2019 Castie!. All rights reserved. | ||
// | ||
|
||
#include "Stack.h" | ||
#include "ArrayList.h" | ||
|
||
void Stack_Print(Stack *stack, StackPrintFunc func) | ||
{ | ||
ArrayList_Print(stack, func); | ||
} | ||
|
||
Stack *Stack_Create(int capaticy) | ||
{ | ||
return ArrayList_Create(capaticy); | ||
} | ||
|
||
void Stack_Destroy(Stack *stack) | ||
{ | ||
ArrayList_Destory(stack); | ||
} | ||
|
||
void Stack_Clear(Stack *stack) | ||
{ | ||
ArrayList_Clear(stack); | ||
} | ||
|
||
void Stack_Push(Stack *stack, StackValue value) | ||
{ | ||
ArrayList_Add(stack, value); | ||
} | ||
|
||
StackValue Stack_Pop(Stack *stack) | ||
{ | ||
return ArrayList_Remove(stack, ArrayList_Length(stack) - 1); | ||
} | ||
|
||
StackValue Stack_Top(Stack *stack) | ||
{ | ||
return ArrayList_Get(stack, ArrayList_Length(stack) - 1); | ||
} | ||
|
||
int Stack_Length(Stack *stack) | ||
{ | ||
return ArrayList_Length(stack); | ||
} |
29 changes: 29 additions & 0 deletions
29
StudyNotes/Foundation/Algorithm4Objective-C/Algorithm4Objective-C/Stack.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// | ||
// Stack.h | ||
// Algorithm4Objective-C | ||
// | ||
// Created by 朱双泉 on 2019/1/24. | ||
// Copyright © 2019 Castie!. All rights reserved. | ||
// | ||
|
||
#ifndef Stack_h | ||
#define Stack_h | ||
|
||
typedef void * StackValue; | ||
typedef void Stack; | ||
typedef void (*StackPrintFunc)(StackValue value); | ||
|
||
#include <stdio.h> | ||
|
||
void Stack_Print(Stack *stack, StackPrintFunc func); | ||
|
||
Stack *Stack_Create(int capaticy); | ||
void Stack_Destroy(Stack *stack); | ||
void Stack_Clear(Stack *stack); | ||
|
||
void Stack_Push(Stack *stack, StackValue value); | ||
StackValue Stack_Pop(Stack *stack); | ||
StackValue Stack_Top(Stack *stack); | ||
int Stack_Length(Stack *stack); | ||
|
||
#endif /* Stack_h */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters