Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Harfbuzz
提交
6c6ccaf5
T
Third Party Harfbuzz
项目概览
OpenHarmony
/
Third Party Harfbuzz
11 个月 前同步成功
通知
0
Star
18
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party Harfbuzz
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6c6ccaf5
编写于
4月 24, 2012
作者:
B
Behdad Esfahbod
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add a few more set operations
TODO: Tests for hb_set_t.
上级
5caece67
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
139 addition
and
4 deletion
+139
-4
src/hb-set-private.hh
src/hb-set-private.hh
+53
-1
src/hb-set.cc
src/hb-set.cc
+55
-0
src/hb-set.h
src/hb-set.h
+31
-3
未找到文件。
src/hb-set-private.hh
浏览文件 @
6c6ccaf5
...
@@ -38,6 +38,12 @@ struct _hb_set_t
...
@@ -38,6 +38,12 @@ struct _hb_set_t
inline
void
clear
(
void
)
{
inline
void
clear
(
void
)
{
memset
(
elts
,
0
,
sizeof
elts
);
memset
(
elts
,
0
,
sizeof
elts
);
}
}
inline
bool
empty
(
void
)
const
{
for
(
unsigned
int
i
=
0
;
i
<
ARRAY_LENGTH
(
elts
);
i
++
)
if
(
elts
[
i
])
return
false
;
return
true
;
}
inline
void
add
(
hb_codepoint_t
g
)
inline
void
add
(
hb_codepoint_t
g
)
{
{
if
(
unlikely
(
g
>
MAX_G
))
return
;
if
(
unlikely
(
g
>
MAX_G
))
return
;
...
@@ -64,19 +70,65 @@ struct _hb_set_t
...
@@ -64,19 +70,65 @@ struct _hb_set_t
return
true
;
return
true
;
return
false
;
return
false
;
}
}
inline
bool
equal
(
const
hb_set_t
*
other
)
const
{
for
(
unsigned
int
i
=
0
;
i
<
ELTS
;
i
++
)
if
(
elts
[
i
]
!=
other
->
elts
[
i
])
return
false
;
return
true
;
}
inline
void
set
(
const
hb_set_t
*
other
)
{
for
(
unsigned
int
i
=
0
;
i
<
ELTS
;
i
++
)
elts
[
i
]
=
other
->
elts
[
i
];
}
inline
void
union_
(
const
hb_set_t
*
other
)
{
for
(
unsigned
int
i
=
0
;
i
<
ELTS
;
i
++
)
elts
[
i
]
|=
other
->
elts
[
i
];
}
inline
void
intersect
(
const
hb_set_t
*
other
)
{
for
(
unsigned
int
i
=
0
;
i
<
ELTS
;
i
++
)
elts
[
i
]
&=
other
->
elts
[
i
];
}
inline
void
subtract
(
const
hb_set_t
*
other
)
{
for
(
unsigned
int
i
=
0
;
i
<
ELTS
;
i
++
)
elts
[
i
]
&=
~
other
->
elts
[
i
];
}
inline
hb_codepoint_t
min
(
void
)
const
{
for
(
unsigned
int
i
=
0
;
i
<
ELTS
;
i
++
)
if
(
elts
[
i
])
for
(
unsigned
int
j
=
0
;
i
<
BITS
;
j
++
)
if
(
elts
[
i
]
&
(
1
<<
j
))
return
i
*
BITS
+
j
;
return
0
;
}
inline
hb_codepoint_t
max
(
void
)
const
{
for
(
unsigned
int
i
=
ELTS
;
i
;
i
--
)
if
(
elts
[
i
-
1
])
for
(
unsigned
int
j
=
BITS
;
j
;
j
--
)
if
(
elts
[
i
-
1
]
&
(
1
<<
(
j
-
1
)))
return
(
i
-
1
)
*
BITS
+
(
j
-
1
);
return
0
;
}
typedef
uint32_t
elt_t
;
typedef
uint32_t
elt_t
;
static
const
unsigned
int
MAX_G
=
65536
-
1
;
static
const
unsigned
int
MAX_G
=
65536
-
1
;
static
const
unsigned
int
SHIFT
=
5
;
static
const
unsigned
int
SHIFT
=
5
;
static
const
unsigned
int
BITS
=
(
1
<<
SHIFT
);
static
const
unsigned
int
BITS
=
(
1
<<
SHIFT
);
static
const
unsigned
int
MASK
=
BITS
-
1
;
static
const
unsigned
int
MASK
=
BITS
-
1
;
static
const
unsigned
int
ELTS
=
(
MAX_G
+
1
+
(
BITS
-
1
))
/
BITS
;
elt_t
&
elt
(
hb_codepoint_t
g
)
{
return
elts
[
g
>>
SHIFT
];
}
elt_t
&
elt
(
hb_codepoint_t
g
)
{
return
elts
[
g
>>
SHIFT
];
}
elt_t
elt
(
hb_codepoint_t
g
)
const
{
return
elts
[
g
>>
SHIFT
];
}
elt_t
elt
(
hb_codepoint_t
g
)
const
{
return
elts
[
g
>>
SHIFT
];
}
elt_t
mask
(
hb_codepoint_t
g
)
const
{
return
elt_t
(
1
)
<<
(
g
&
MASK
);
}
elt_t
mask
(
hb_codepoint_t
g
)
const
{
return
elt_t
(
1
)
<<
(
g
&
MASK
);
}
hb_object_header_t
header
;
hb_object_header_t
header
;
elt_t
elts
[
(
MAX_G
+
1
+
(
BITS
-
1
))
/
BI
TS
];
/* 8kb */
elt_t
elts
[
EL
TS
];
/* 8kb */
ASSERT_STATIC
(
sizeof
(
elt_t
)
*
8
==
BITS
);
ASSERT_STATIC
(
sizeof
(
elt_t
)
*
8
==
BITS
);
ASSERT_STATIC
(
sizeof
(
elts
)
*
8
>
MAX_G
);
ASSERT_STATIC
(
sizeof
(
elts
)
*
8
>
MAX_G
);
...
...
src/hb-set.cc
浏览文件 @
6c6ccaf5
...
@@ -28,6 +28,8 @@
...
@@ -28,6 +28,8 @@
/* Public API */
static
hb_set_t
_hb_set_nil
=
{
static
hb_set_t
_hb_set_nil
=
{
HB_OBJECT_HEADER_STATIC
,
HB_OBJECT_HEADER_STATIC
,
...
@@ -98,6 +100,12 @@ hb_set_clear (hb_set_t *set)
...
@@ -98,6 +100,12 @@ hb_set_clear (hb_set_t *set)
set
->
clear
();
set
->
clear
();
}
}
hb_bool_t
hb_set_empty
(
hb_set_t
*
set
)
{
return
set
->
empty
();
}
hb_bool_t
hb_bool_t
hb_set_has
(
hb_set_t
*
set
,
hb_set_has
(
hb_set_t
*
set
,
hb_codepoint_t
codepoint
)
hb_codepoint_t
codepoint
)
...
@@ -118,3 +126,50 @@ hb_set_del (hb_set_t *set,
...
@@ -118,3 +126,50 @@ hb_set_del (hb_set_t *set,
{
{
set
->
del
(
codepoint
);
set
->
del
(
codepoint
);
}
}
hb_bool_t
hb_set_equal
(
hb_set_t
*
set
,
hb_set_t
*
other
)
{
return
set
->
equal
(
other
);
}
void
hb_set_set
(
hb_set_t
*
set
,
hb_set_t
*
other
)
{
set
->
set
(
other
);
}
void
hb_set_union
(
hb_set_t
*
set
,
hb_set_t
*
other
)
{
set
->
union_
(
other
);
}
void
hb_set_intersect
(
hb_set_t
*
set
,
hb_set_t
*
other
)
{
set
->
intersect
(
other
);
}
void
hb_set_subtract
(
hb_set_t
*
set
,
hb_set_t
*
other
)
{
set
->
subtract
(
other
);
}
hb_codepoint_t
hb_set_min
(
hb_set_t
*
set
)
{
return
set
->
min
();
}
hb_codepoint_t
hb_set_max
(
hb_set_t
*
set
)
{
return
set
->
max
();
}
src/hb-set.h
浏览文件 @
6c6ccaf5
...
@@ -52,14 +52,14 @@ void
...
@@ -52,14 +52,14 @@ void
hb_set_destroy
(
hb_set_t
*
set
);
hb_set_destroy
(
hb_set_t
*
set
);
hb_bool_t
hb_bool_t
hb_set_set_user_data
(
hb_set_t
*
set
,
hb_set_set_user_data
(
hb_set_t
*
set
,
hb_user_data_key_t
*
key
,
hb_user_data_key_t
*
key
,
void
*
data
,
void
*
data
,
hb_destroy_func_t
destroy
,
hb_destroy_func_t
destroy
,
hb_bool_t
replace
);
hb_bool_t
replace
);
void
*
void
*
hb_set_get_user_data
(
hb_set_t
*
set
,
hb_set_get_user_data
(
hb_set_t
*
set
,
hb_user_data_key_t
*
key
);
hb_user_data_key_t
*
key
);
...
@@ -70,6 +70,9 @@ hb_set_allocation_successful (hb_set_t *set);
...
@@ -70,6 +70,9 @@ hb_set_allocation_successful (hb_set_t *set);
void
void
hb_set_clear
(
hb_set_t
*
set
);
hb_set_clear
(
hb_set_t
*
set
);
hb_bool_t
hb_set_empty
(
hb_set_t
*
set
);
hb_bool_t
hb_bool_t
hb_set_has
(
hb_set_t
*
set
,
hb_set_has
(
hb_set_t
*
set
,
hb_codepoint_t
codepoint
);
hb_codepoint_t
codepoint
);
...
@@ -82,8 +85,33 @@ void
...
@@ -82,8 +85,33 @@ void
hb_set_del
(
hb_set_t
*
set
,
hb_set_del
(
hb_set_t
*
set
,
hb_codepoint_t
codepoint
);
hb_codepoint_t
codepoint
);
/* TODO: add union, intersect, subtract, equal, empty, min, max, iter, etc */
hb_bool_t
hb_set_equal
(
hb_set_t
*
set
,
hb_set_t
*
other
);
void
hb_set_set
(
hb_set_t
*
set
,
hb_set_t
*
other
);
void
hb_set_union
(
hb_set_t
*
set
,
hb_set_t
*
other
);
void
hb_set_intersect
(
hb_set_t
*
set
,
hb_set_t
*
other
);
void
hb_set_subtract
(
hb_set_t
*
set
,
hb_set_t
*
other
);
hb_codepoint_t
hb_set_min
(
hb_set_t
*
set
);
hb_codepoint_t
hb_set_max
(
hb_set_t
*
set
);
/* TODO: Add faster iteration API? */
HB_END_DECLS
HB_END_DECLS
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录