Red-Black tree by Golang

1,446 views
Skip to first unread message

huke...@huawei.com

unread,
Jun 3, 2015, 12:19:10 AM6/3/15
to golan...@googlegroups.com
Hi there,

Since we should not add new container data structures into the standard library, but the Red-Black tree is quite useful in some scenarios, so I put it on Github,

PR is welcome:)


I'v made a simple test for inserting  and deleting  1,000.000 integers and record the time it cost, seems quite good

Rbtree:1000000
Befor Insert:2015-06-03 05:36:38.202131403 +0800 CST
After Insert:2015-06-03 05:36:40.3821364 +0800 CST
After delete:2015-06-03 05:36:41.586501826 +0800 CST
time2 - time1:2.180004997
time3 - time2:1.204365426

Nate Finch

unread,
Jun 4, 2015, 10:52:00 PM6/4/15
to golan...@googlegroups.com
Your license and copyright all specify the go authors... but I don't think you're allowed to license things for other people like that.  You should change the license and copyright to specify yourself.

Nick Craig-Wood

unread,
Jun 5, 2015, 4:20:42 AM6/5/15
to huke...@huawei.com, golan...@googlegroups.com
Interesting!

For this sort of code I'd expect to see near 100% test coverage though

github.com/HuKeping/rbtree$ go test -v -cover -coverprofile cover.out
=== RUN TestInsertInt
--- PASS: TestInsertInt (0.00s)
=== RUN TestInsertString
--- PASS: TestInsertString (0.00s)
=== RUN TestInsertDup
--- PASS: TestInsertDup (0.00s)
=== RUN TestDelete
--- PASS: TestDelete (0.00s)
=== RUN TestDescend
--- PASS: TestDescend (0.00s)
PASS
coverage: 42.2% of statements
ok github.com/HuKeping/rbtree 0.004s


--
Nick Craig-Wood <ni...@craig-wood.com> -- http://www.craig-wood.com/nick

huke...@huawei.com

unread,
Jun 7, 2015, 10:56:01 PM6/7/15
to golan...@googlegroups.com


在 2015年6月5日星期五 UTC+8上午10:52:00,Nate Finch写道:
Your license and copyright all specify the go authors... but I don't think you're allowed to license things for other people like that.  You should change the license and copyright to specify yourself.

Thanks, I'll update that 

huke...@huawei.com

unread,
Jun 7, 2015, 10:57:53 PM6/7/15
to golan...@googlegroups.com, huke...@huawei.com


在 2015年6月5日星期五 UTC+8下午4:20:42,Nick Craig-Wood写道:
On 03/06/15 03:11, huke...@huawei.com wrote:
> Since we should not add new container data structures into the standard
> library, but the Red-Black tree is quite useful in some scenarios, so I
> put it on Github,
>
> PR is welcome:)
>
> https://github.com/HuKeping/rbtree
>
> I'v made a simple test for inserting  and deleting  1,000.000 integers
> and record the time it cost, seems quite good
>
> Rbtree:1000000
> Befor Insert:2015-06-03 05:36:38.202131403 +0800 CST
> After Insert:2015-06-03 05:36:40.3821364 +0800 CST
> After delete:2015-06-03 05:36:41.586501826 +0800 CST
> time2 - time1:2.180004997
> time3 - time2:1.204365426

Interesting!

For this sort of code I'd expect to see near 100% test coverage though

 
I've  upgraded the test and get a better coverage now :)
Reply all
Reply to author
Forward
0 new messages