# 环形数组例程

#define CIRCLEBUFFER_SIZE    8
unsigned char CircleBuffer[CIRCLEBUFFER_SIZE];
unsigned char WriteIndex = 0;
unsigned char LeftSize = 0;

//检查是否有到数组末尾了
unsigned char Check_CircleBuffer(unsigned char i)
{
return(i + 1) ==  CIRCLEBUFFER_SIZE?0:i+1;
}

//从环形数组里读取数据
{
unsigned char Pos;
if(LeftSize > 0)
{
LeftSize--;
return CircleBuffer[Pos];
}
return 0;
}

//往环形数组内写入数据
void Write_CircleBuffer_Data(unsigned char Data)
{
if(LeftSize < CIRCLEBUFFER_SIZE)
{
CircleBuffer[WriteIndex] = Data;
WriteIndex = Check_CircleBuffer(WriteIndex);
LeftSize++;
}
}

void main(void)
{
Write_CircleBuffer_Data(1);
}

#### 数组实现的 环形队列

2017-03-01 10:21:16

#### 算法-一种数组环形队列的数据结构

2016-08-13 16:00:25

#### c语言数据结构实现-数组队列/环形队列

2016-12-15 22:50:23

#### 环形队列的数组实现

2016-08-22 15:09:21

#### 环形buffer 环形数组等原理例程

2018-05-23 17:47:39

#### 无锁队列的环形数组实现（Lock Free Queue Implementation in Ring Array）

2014-06-02 12:27:26

#### java 环形数组缓冲区

2016-09-04 19:03:01

#### 环形队列实现原理

2011-07-09 09:28:55

#### 环形缓存区bufferC语言实现

2013-02-05 10:03:37

#### C语言数组实现队列

2013-11-09 20:25:53