Zig utility library
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

add `isEmpty` to `RingBuffer`

IamPyu 34a47b35 5ecc956b

+7 -3
+7 -3
src/data/RingBuffer.zig
··· 29 29 self.write_index = (self.write_index + 1) % capacity; 30 30 } 31 31 32 - /// Get a reference to the value being pointed by the read index 32 + pub fn isEmpty(self: *const Self) bool { 33 + return self.read_index == self.write_index; 34 + } 35 + 36 + /// Get a pointer to the value being pointed by the read index 33 37 pub fn get(self: *Self) ?*T { 34 - if (self.read_index == self.write_index) { 38 + if (self.isEmpty()) { 35 39 return null; 36 40 } 37 41 ··· 41 45 42 46 /// Remove the value being pointed by the read index, returning the value 43 47 pub fn read(self: *Self) ?T { 44 - if (self.read_index == self.write_index) { 48 + if (self.isEmpty()) { 45 49 return null; 46 50 } 47 51