Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
e68b0193
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e68b0193
编写于
12月 21, 2015
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
debt - no code is the best code, remove more unsued types and functions
上级
575cbbde
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
4 addition
and
165 deletion
+4
-165
src/vs/base/common/collections.ts
src/vs/base/common/collections.ts
+4
-165
未找到文件。
src/vs/base/common/collections.ts
浏览文件 @
e68b0193
...
...
@@ -90,25 +90,6 @@ export function contains<T>(from:any, what:any):boolean {
return
hasOwnProperty
.
call
(
from
,
what
);
}
export
function
keys
<
T
>
(
from
:
IStringDictionary
<
T
>
):
IIterable
<
string
>
;
export
function
keys
<
T
>
(
from
:
INumberDictionary
<
T
>
):
IIterable
<
number
>
;
export
function
keys
<
T
>
(
from
:
any
):
IIterable
<
any
>
{
return
{
every
:
function
(
callback
:(
element
:
any
)
=>
boolean
):
boolean
{
for
(
var
key
in
from
)
{
if
(
hasOwnProperty
.
call
(
from
,
key
))
{
if
(
!
callback
(
key
))
{
return
false
;
}
}
}
return
true
;
}
};
}
/**
* Returns an array which contains all values that reside
* in the given set.
...
...
@@ -167,145 +148,3 @@ export function groupBy<T>(data: T[], groupFn: (element: T) => string): IStringD
data
.
forEach
(
element
=>
lookupOrInsert
(
result
,
groupFn
(
element
),
[]).
push
(
element
));
return
result
;
}
/**
* An iterable of a given type. This iterable is
* compatible with the JavaScript array.
*/
export
interface
IIterable
<
E
>
{
/**
* Iterates over every element in the array
* as long as the callback does not return some
* 'falsy' value.
* @param callback A function that is called for each element
* @return {{true}} if every element has been visited,
* {{false}} if it returned early
*/
every
(
callback
:(
element
:
E
)
=>
boolean
):
boolean
;
}
export
var
EmptyIterable
:
IIterable
<
any
>
=
{
every
:
function
(
callback
)
{
return
true
;
}
};
export
function
combine
<
E
>
(
iterables
:
IIterable
<
E
>
[]):
IIterable
<
E
>
{
var
len
=
iterables
.
length
;
if
(
len
===
0
)
{
return
EmptyIterable
;
}
else
if
(
len
===
1
)
{
return
iterables
[
0
];
}
return
{
every
:
function
(
callback
:(
element
:
E
)
=>
any
)
{
for
(
var
i
=
0
;
i
<
len
;
i
++
)
{
if
(
!
iterables
[
i
].
every
(
callback
))
{
return
false
;
}
}
return
true
;
}
};
}
export
function
singleton
<
E
>
(
element
:
E
):
IIterable
<
E
>
{
return
{
every
:
function
(
callback
)
{
return
callback
(
element
);
}
};
}
export
function
toArray
<
E
>
(
iterable
:
IIterable
<
E
>
):
E
[]
{
if
(
Array
.
isArray
(
iterable
))
{
return
<
E
[]
>
iterable
;
}
else
{
var
result
:
E
[]
=
[];
iterable
.
every
((
e
)
=>
{
result
.
push
(
e
);
return
true
;
});
return
result
;
}
}
///**
// * ECMAScript 6 iterator
// */
//export interface IIterator<T> {
// next(): { done: boolean; value?: T; };
//}
//
//export function empty<T>():IIterator<T> {
// return {
// next: function() { return { done: true }; }
// };
//}
//
//export function iterator<T>(array: T[]): IIterator<T> {
// var i = 0;
// return {
// next: () => {
// if(i < array.length) {
// return {
// done: false,
// value: array[i++]
// };
// } else {
// return {
// done: true
// };
// }
// }
// };
//}
interface
ICacheRow
<
T
>
{
element
:
T
;
onRemove
:
()
=>
void
;
}
/**
* Limited size cache. Provided a certain cache size limit, it
* removes the older elements as new ones are inserted.
*/
export
class
LimitedSizeCache
<
T
>
{
private
cache
:
{
[
id
:
string
]:
ICacheRow
<
T
>
};
private
order
:
string
[];
constructor
(
private
size
:
number
)
{
this
.
cache
=
Object
.
create
(
null
);
this
.
order
=
[];
}
public
get
(
id
:
string
):
T
{
var
result
=
this
.
cache
[
id
];
return
result
&&
result
.
element
;
}
public
put
(
id
:
string
,
element
:
T
,
onRemove
:
()
=>
void
):
void
{
var
existing
=
this
.
cache
[
id
];
var
row
:
ICacheRow
<
T
>
=
{
element
:
element
,
onRemove
:
onRemove
};
this
.
cache
[
id
]
=
row
;
if
(
!
existing
)
{
this
.
order
.
push
(
id
);
}
this
.
swipe
();
}
private
swipe
():
void
{
while
(
this
.
order
.
length
>
this
.
size
)
{
var
id
=
this
.
order
.
shift
();
var
row
=
this
.
cache
[
id
];
row
.
onRemove
();
delete
this
.
cache
[
id
];
}
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录