Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenDocCN
TinySTL
提交
55fb8702
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,发现更多精彩内容 >>
提交
55fb8702
编写于
10月 23, 2014
作者:
邹
邹晓航
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
bug fix && add two ctors
上级
e297f98b
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
32 addition
and
1 deletion
+32
-1
TinySTL/Deque.h
TinySTL/Deque.h
+32
-1
未找到文件。
TinySTL/Deque.h
浏览文件 @
55fb8702
...
...
@@ -139,6 +139,8 @@ namespace TinySTL{
}
template
<
class
T
>
typename
dq_iter
<
T
>::
difference_type
operator
-
(
const
dq_iter
<
T
>&
it1
,
const
dq_iter
<
T
>&
it2
){
if
(
it1
.
container_
==
it2
.
container_
&&
it1
.
container_
==
0
)
return
0
;
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
;
}
...
...
@@ -168,6 +170,9 @@ namespace TinySTL{
T
**
map_
;
public:
deque
();
explicit
deque
(
size_type
n
,
const
value_type
&
val
=
value_type
());
template
<
class
InputIterator
>
deque
(
InputIterator
first
,
InputIterator
last
);
deque
(
const
deque
&
x
);
~
deque
(){
...
...
@@ -240,6 +245,21 @@ namespace TinySTL{
bool
front_full
()
const
{
return
map_
[
0
]
&&
map_
[
0
]
==
begin
().
cur_
;
}
void
deque_aux
(
size_t
n
,
const
value_type
&
val
,
std
::
true_type
){
int
i
=
0
;
for
(;
i
!=
n
/
2
;
++
i
)
(
*
this
).
push_front
(
val
);
for
(;
i
!=
n
;
++
i
)
(
*
this
).
push_back
(
val
);
}
template
<
class
Iterator
>
void
deque_aux
(
Iterator
first
,
Iterator
last
,
std
::
false_type
){
difference_type
mid
=
(
last
-
first
)
/
2
;
for
(
auto
it
=
first
+
mid
;
it
>=
first
;
--
it
)
(
*
this
).
push_front
(
*
it
);
for
(
auto
it
=
first
+
mid
+
1
;
it
!=
last
;
++
it
)
(
*
this
).
push_back
(
*
it
);
}
void
reallocateAndCopy
();
public:
template
<
class
T
,
class
Alloc
>
...
...
@@ -261,6 +281,17 @@ namespace TinySTL{
template
<
class
T
,
class
Alloc
>
deque
<
T
,
Alloc
>::
deque
()
:
mapSize_
(
0
),
map_
(
0
){}
template
<
class
T
,
class
Alloc
>
deque
<
T
,
Alloc
>::
deque
(
size_type
n
,
const
value_type
&
val
=
value_type
()){
deque
();
deque_aux
(
n
,
val
,
typename
std
::
is_integral
<
size_type
>::
type
());
}
template
<
class
T
,
class
Alloc
>
template
<
class
InputIterator
>
deque
<
T
,
Alloc
>::
deque
(
InputIterator
first
,
InputIterator
last
){
deque
();
deque_aux
(
first
,
last
,
typename
std
::
is_integral
<
InputIterator
>::
type
());
}
/*template<class T, class Alloc>
deque<T, Alloc>::deque(const deque& x){
...
...
@@ -309,7 +340,7 @@ namespace TinySTL{
template
<
class
T
,
class
Alloc
>
void
deque
<
T
,
Alloc
>::
pop_front
(){
dataAllocator
::
destroy
(
beg_
.
cur_
);
--
beg_
;
++
beg_
;
}
template
<
class
T
,
class
Alloc
>
void
deque
<
T
,
Alloc
>::
pop_back
(){
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录