Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenDocCN
TinySTL
提交
e435631d
T
TinySTL
项目概览
OpenDocCN
/
TinySTL
通知
4
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TinySTL
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e435631d
编写于
10月 23, 2014
作者:
邹
邹晓航
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
dq_iter swap bug fix
上级
b7643e82
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
33 addition
and
11 deletion
+33
-11
TinySTL/Deque.h
TinySTL/Deque.h
+33
-11
未找到文件。
TinySTL/Deque.h
浏览文件 @
e435631d
...
...
@@ -34,6 +34,11 @@ namespace TinySTL{
}
return
*
this
;
}
void
swap
(
dq_iter
&
it
){
TinySTL
::
swap
(
mapIndex_
,
it
.
mapIndex_
);
TinySTL
::
swap
(
cur_
,
it
.
cur_
);
//TinySTL::swap(container_, it.container_);
}
reference
operator
*
(){
return
*
cur_
;
}
pointer
operator
->
(){
return
&
(
operator
*
());
}
dq_iter
&
operator
++
(){
...
...
@@ -99,6 +104,8 @@ namespace TinySTL{
friend
dq_iter
<
T
>
operator
-
(
typename
dq_iter
<
T
>::
difference_type
n
,
const
dq_iter
<
T
>&
it
);
template
<
class
T
>
friend
typename
dq_iter
<
T
>::
difference_type
operator
-
(
const
dq_iter
<
T
>&
it1
,
const
dq_iter
<
T
>&
it2
);
template
<
class
T
>
friend
void
swap
(
dq_iter
<
T
>&
lhs
,
dq_iter
<
T
>&
rhs
);
};
template
<
class
T
>
dq_iter
<
T
>
operator
+
(
const
dq_iter
<
T
>&
it
,
typename
dq_iter
<
T
>::
difference_type
n
){
//assume n >= 0
...
...
@@ -144,6 +151,10 @@ namespace TinySTL{
return
typename
dq_iter
<
T
>::
difference_type
(
it1
.
getBuckSize
())
*
(
it1
.
mapIndex_
-
it2
.
mapIndex_
-
1
)
+
(
it1
.
cur_
-
it1
.
getBuckHead
(
it1
.
mapIndex_
))
+
(
it2
.
getBuckTail
(
it2
.
mapIndex_
)
-
it2
.
cur_
)
+
1
;
}
template
<
class
T
>
void
swap
(
dq_iter
<
T
>&
lhs
,
dq_iter
<
T
>&
rhs
){
lhs
.
swap
(
rhs
);
}
}
//class of deque
...
...
@@ -266,14 +277,6 @@ namespace TinySTL{
template
<
class
T
,
class
Alloc
>
friend
bool
operator
!=
(
const
deque
<
T
,
Alloc
>&
lhs
,
const
deque
<
T
,
Alloc
>&
rhs
);
template
<
class
T
,
class
Alloc
>
friend
bool
operator
<
(
const
deque
<
T
,
Alloc
>&
lhs
,
const
deque
<
T
,
Alloc
>&
rhs
);
template
<
class
T
,
class
Alloc
>
friend
bool
operator
<=
(
const
deque
<
T
,
Alloc
>&
lhs
,
const
deque
<
T
,
Alloc
>&
rhs
);
template
<
class
T
,
class
Alloc
>
friend
bool
operator
>
(
const
deque
<
T
,
Alloc
>&
lhs
,
const
deque
<
T
,
Alloc
>&
rhs
);
template
<
class
T
,
class
Alloc
>
friend
bool
operator
>=
(
const
deque
<
T
,
Alloc
>&
lhs
,
const
deque
<
T
,
Alloc
>&
rhs
);
template
<
class
T
,
class
Alloc
>
friend
void
swap
(
deque
<
T
,
Alloc
>&
x
,
deque
<
T
,
Alloc
>&
y
);
};
//end of deque
...
...
@@ -356,11 +359,30 @@ namespace TinySTL{
dataAllocator
::
destroy
(
end_
.
cur_
);
}
template
<
class
T
,
class
Alloc
>
void
deque
<
T
,
Alloc
>::
swap
(
deque
&
x
){
TinySTL
::
swap
(
beg_
,
x
.
beg_
);
TinySTL
::
swap
(
end_
,
x
.
end_
);
void
deque
<
T
,
Alloc
>::
swap
(
deque
<
T
,
Alloc
>&
x
){
TinySTL
::
swap
(
mapSize_
,
x
.
mapSize_
);
TinySTL
::
swap
(
map_
,
x
.
map_
);
beg_
.
swap
(
x
.
beg_
);
end_
.
swap
(
x
.
end_
);
}
template
<
class
T
,
class
Alloc
>
bool
operator
==
(
const
deque
<
T
,
Alloc
>&
lhs
,
const
deque
<
T
,
Alloc
>&
rhs
){
auto
cit1
=
lhs
.
cbegin
(),
cit2
=
rhs
.
cbegin
();
for
(;
cit1
!=
lhs
.
cend
()
&&
cit2
!=
rhs
.
cend
();
++
cit1
,
++
cit2
){
if
(
*
cit1
!=
*
cit2
)
return
false
;
}
if
(
cit1
==
lhs
.
cend
()
&&
cit2
==
rhs
.
cend
())
return
true
;
return
false
;
}
template
<
class
T
,
class
Alloc
>
bool
operator
!=
(
const
deque
<
T
,
Alloc
>&
lhs
,
const
deque
<
T
,
Alloc
>&
rhs
){
return
!
(
lhs
==
rhs
);
}
template
<
class
T
,
class
Alloc
>
void
swap
(
deque
<
T
,
Alloc
>&
x
,
deque
<
T
,
Alloc
>&
y
){
x
.
swap
(
y
);
}
}
#endif
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录