exportSprite之七(Chunk,Stack)

本文详细解析了Chunk.java和Stack.java文件的源码,深入理解这两个类的功能和内部实现,包括数据结构、成员变量以及核心方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Chunk.java文件源码:<wbr style="line-height:25px"><div style="line-height:25px"> <div style="line-height:25px">import java.io.*;</div> <div style="line-height:25px"><br style="line-height:25px"></div> <div style="line-height:25px"><span style="color:#993300; line-height:25px">public class Chunk</span></div> <div style="line-height:25px">{</div> <div style="line-height:25px"><br style="line-height:25px"></div> <div style="line-height:25px"> int len = 0;</div> <div style="line-height:25px"> byte type[] = new byte[4];</div> <div style="line-height:25px"> byte data[];</div> <div style="line-height:25px"> int crc;</div> <div style="line-height:25px"> Chunk()</div> <div style="line-height:25px"> {}</div> <div style="line-height:25px"> <span style="color:#FF6600; line-height:25px">Chunk(DataInputStream in)</span> </div> <div style="line-height:25px"> {</div> <div style="line-height:25px"> read(in);</div> <div style="line-height:25px"> }</div> <div style="line-height:25px"> <span style="color:#FF6600; line-height:25px">void read(DataInputStream in)</span> </div> <div style="line-height:25px"> {</div> <div style="line-height:25px"> try</div> <div style="line-height:25px"> {</div> <div style="line-height:25px"> len=in.readInt();</div> <div style="line-height:25px"> data=new byte[len];</div> <div style="line-height:25px"> in.read(type);</div> <div style="line-height:25px"> in.read(data);</div> <div style="line-height:25px"> crc=in.readInt();</div> <div style="line-height:25px"> } catch (Exception e)</div> <div style="line-height:25px"> {</div> <div style="line-height:25px"> }</div> <div style="line-height:25px"> }</div> <div style="line-height:25px">}</div> </div> <div style="line-height:25px"> <span style="line-height:25px">Stack.java文件源码</span>:</div> <div style="line-height:25px"> <div style="line-height:25px"> <span style="color:#993300; line-height:25px">public class Stack</span>{</div> <div style="line-height:25px"> int stack[];</div> <div style="line-height:25px"> int curse;</div> <div style="line-height:25px"> final static int kDefaultStackSizeMax=10;</div> <div style="line-height:25px"> <span style="color:#FF6600; line-height:25px">Stack()</span> </div> <div style="line-height:25px"> {</div> <div style="line-height:25px"> stack=new int [kDefaultStackSizeMax];</div> <div style="line-height:25px"> }</div> <div style="line-height:25px"> <span style="color:#FF6600; line-height:25px">void stack(int stackMax)</span> </div> <div style="line-height:25px"> {</div> <div style="line-height:25px"> stack=new int [stackMax];</div> <div style="line-height:25px"> }</div> <div style="line-height:25px"> <span style="color:#FF6600; line-height:25px">void creatStack(int stackMax)</span> </div> <div style="line-height:25px"> {</div> <div style="line-height:25px"> stack=new int [stackMax];</div> <div style="line-height:25px"> }</div> <div style="line-height:25px"> <span style="color:#FF6600; line-height:25px">void push(int value)</span> </div> <div style="line-height:25px"> {</div> <div style="line-height:25px"> stack[curse++]=value;</div> <div style="line-height:25px"> }</div> <div style="line-height:25px"> <span style="color:#FF6600; line-height:25px">int pop()</span> </div> <div style="line-height:25px"> {</div> <div style="line-height:25px"> if(isEmpty())</div> <div style="line-height:25px"> return -1;</div> <div style="line-height:25px"> curse--;</div> <div style="line-height:25px"> return stack[curse];</div> <div style="line-height:25px"> }</div> <div style="line-height:25px"> <span style="color:#FF6600; line-height:25px">int getTopValue()</span> </div> <div style="line-height:25px"> {</div> <div style="line-height:25px"> if(isEmpty())</div> <div style="line-height:25px"> return -1;</div> <div style="line-height:25px"> return stack[curse-1];</div> <div style="line-height:25px"> </div> <div style="line-height:25px"> }</div> <div style="line-height:25px"> <span style="color:#FF6600; line-height:25px">void popAll()</span> </div> <div style="line-height:25px"> {</div> <div style="line-height:25px"> curse=0;</div> <div style="line-height:25px"> }</div> <div style="line-height:25px"> <span style="color:#FF6600; line-height:25px">boolean isEmpty()</span> </div> <div style="line-height:25px"> {</div> <div style="line-height:25px"> return curse==0;</div> <div style="line-height:25px"> }</div> <div style="line-height:25px">}</div> </div> </wbr>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值