How to append two arrays without copying characters???

eric8024 2004-04-23 11:18:10
I need to append two arrays. But I don't know how to append them without copying characters. Can someone help me?

Thx in advance!

Details are listed as following:

public Cord(String init) (constructor)
Create a cord whose content is the string init

public Cord append(Cord other)
Return a cord containing all the characters of the original cord, followed by all of the characters of other. Note that this method should not modify the original cord.


Your implementation must not use the java String class to store the data; the data should be stored in arrays of characters.

To avoid copying, you will need to make each cord be a sequence of “cord segments,” where each cord segment contains an array of characters, plus the index of the first character to use and either the length or the index of the last character to use.
...全文
137 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
Campfire 2004-04-27
  • 打赏
  • 举报
回复
Learning...
Up
Sheepy 2004-04-24
  • 打赏
  • 举报
回复
their implementation, spelling mistake.
Sheepy 2004-04-24
  • 打赏
  • 举报
回复
how come your requirements so wired?
i tell ya what, both String and StringBuffer use char array in there implementation.

62,623

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧