100-Days-Of-iOS-DataStructure-Algorithm icon indicating copy to clipboard operation
100-Days-Of-iOS-DataStructure-Algorithm copied to clipboard

Queue的方法isEmpty实现有些问题?

Open ghost opened this issue 3 years ago • 0 comments

应该使用如下的方法实现吧?

- (BOOL)isEmpty
{
//    if (self.queueArray.count == 0)
    if (self.countOfQueue == 0)
    {
        return YES;
    }
    return NO;
}


- (NSInteger)countOfQueue
{
//    return self.queueArray.count;
    return self.queueArray.count - self.headIndex;
}

ghost avatar Apr 19 '22 02:04 ghost