堆栈

堆栈的链式存储实现:

直接上代码:

栈类:

//仅仅是为了复习用,为了省时间,我把判断是否出界等功能省了
public class Stack{
 	int Len;
 	Node head;
 	public Stack() {
  		this.head=null;
  		this.Len=0;
 	}
 	public void Push(int data) {
  		Node node=new Node(data);
  		Node flag=null;
  		flag=this.head;
  		this.head=node;
  		node=flag;
  		this.head.next=node;
  		this.Len++;
 	}//压栈操作
 	public void Pull() {
  		System.out.println(this.head.data+"出栈");
  		this.head=this.head.next;
  		this.Len--;
 	}//出栈操作
 	public void Print() {
  		Node a;
  		a=this.head;
  		for(int i=this.Len;i>0;i--) {
   			System.out.println(a.data+"  ");
   			a=a.next;
  		}
 	}//打印操作
}

节点类:

public class Node {
 	int data;
 	Node next;
 	public Node(int Data) {
  		this.data=Data;
  		this.next=null;
 	}
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Freertos堆栈和启动文件堆栈是两个不同的概念。在Freertos堆栈是用来保存任务的上下文信息的内存区域,用于任务切换时保存和恢复任务的执行状态。而启动文件堆栈是用来为整个程序提供内存空间的,包括全局变量、静态变量等。 在Freertos,堆的大小可以通过在FreeRTOSConfig.h文件设置configTOTAL_HEAP_SIZE来指定。这个值决定了Freertos可以使用的堆的总大小。根据经验,堆的大小应该设置得足够大,以满足任务的内存需求。 而启动文件堆栈大小与Freertos的堆大小没有直接关系。启动文件堆栈大小是用来为整个程序提供内存空间的,包括全局变量、静态变量等。在使用Freertos时,启动文件堆栈大小可以根据以下公式来设置:启动文件的heap_size = mcu运行时的ram空间 - RW-Data - ZI-Data - Freertos设置的堆大小。 总结起来,Freertos堆栈和启动文件堆栈是两个不同的概念,它们的大小设置是独立的。在使用Freertos时,需要根据任务的内存需求来设置Freertos的堆大小,并根据公式来设置启动文件堆栈大小,以确保程序的正常运行。 #### 引用[.reference_title] - *1* *2* *3* [stm32以及freertos 堆栈解析](https://blog.csdn.net/sinat_36568888/article/details/124320985)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值