English 中文(简体)
如何在两班之间分享联系名单
原标题:how can i share a linked list between two classes
  • 时间:2009-10-02 07:49:08
  •  标签:

supposed i created a linked list in class A how can class B access it? please give me some examples if any many thanks

问题回答

如果相关名单由A类保留的话。 您应建立一个可供B类使用的接口。

我想:

  • Add, to add to the linked list
  • Delete, to delete from the linked list
  • Replace, to replace an item
  • Lookup, to get an item from the list.
  • Length, to get the length of the list.

可能还会有更多的(像老板一样)但应该满足你们的需要。

另一种选择是,在A类和B类之外建立这种设施,并将其传授给正在施工的班级。

一种办法是通过建筑商将清单传送给两个班。

List<X> list = new LinkedList<X>();
A a = new A(list);
B b = new B(list);

它是否必须是一份相互关联的清单? 如果你利用你能够控制记忆空间的不同结构,你可以 n地利用共享记忆。

你可以创造朋友职能,在A类和B类链接名单上添加、删除、打字和其他行动,可以使用。





相关问题
热门标签