mirror of
https://gitee.com/apaki/unicstl.git
synced 2025-07-03 15:56:52 +08:00
还是不对,这么处理感觉好复杂啊,是不是我全部修改为闭区间容易处理一点?
This commit is contained in:
parent
3f8f418d4e
commit
46caba5943
90
src/list.c
90
src/list.c
@ -347,11 +347,61 @@ done:
|
|||||||
bool contain_last_obj = false;
|
bool contain_last_obj = false;
|
||||||
int temp = 0;
|
int temp = 0;
|
||||||
bool negative = false;
|
bool negative = false;
|
||||||
|
|
||||||
|
int start0 = start;
|
||||||
|
int end0 = end;
|
||||||
if (step == 0)
|
if (step == 0)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(start0 == LIST_UNLIMITED)
|
||||||
|
{
|
||||||
|
start = 0 - (int)LIST_UNLIMITED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(end0 == LIST_UNLIMITED)
|
||||||
|
{
|
||||||
|
end = (int)LIST_UNLIMITED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(start < 0)
|
||||||
|
{
|
||||||
|
start += (int)self->size(self);
|
||||||
|
if(start < 0)
|
||||||
|
{
|
||||||
|
start = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(start >= (int)self->size(self))
|
||||||
|
{
|
||||||
|
empty = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(end < 0)
|
||||||
|
{
|
||||||
|
end += (int)self->size(self);
|
||||||
|
if(end < 0)
|
||||||
|
{
|
||||||
|
empty = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (end >= (int)self->size(self))
|
||||||
|
{
|
||||||
|
end = (int)self->size(self);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(step < 0)
|
||||||
|
{
|
||||||
|
contain_last_obj = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(step < 0)
|
if(step < 0)
|
||||||
{
|
{
|
||||||
negative = true;
|
negative = true;
|
||||||
@ -375,45 +425,7 @@ done:
|
|||||||
{
|
{
|
||||||
end = temp;
|
end = temp;
|
||||||
}
|
}
|
||||||
}
|
end = temp;
|
||||||
|
|
||||||
if(start < 0)
|
|
||||||
{
|
|
||||||
start += (int)self->size(self);
|
|
||||||
if(start < 0)
|
|
||||||
{
|
|
||||||
start = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if(start == LIST_UNLIMITED)
|
|
||||||
{
|
|
||||||
start = 0;
|
|
||||||
contain_last_obj = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(start >= (int)self->size(self))
|
|
||||||
{
|
|
||||||
empty = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(end < 0)
|
|
||||||
{
|
|
||||||
end += (int)self->size(self);
|
|
||||||
if(end < 0)
|
|
||||||
{
|
|
||||||
empty = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (end == LIST_UNLIMITED || end >= (int)self->size(self))
|
|
||||||
{
|
|
||||||
end = (int)self->size(self) - 1;
|
|
||||||
contain_last_obj = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(start >= end)
|
if(start >= end)
|
||||||
|
Loading…
Reference in New Issue
Block a user