queue - How to make a shallow copy of a list Java -
i've made class revolved around implementing queues using linked list. implementation works fine. however, have write constructor passed queue, , has make duplicate of original queue. duplicate, mean elements in each queue same, actual nodes not. how go doing this?
p.s. may not use collections class means no clone() method.
from described algorithm achieve be:
- write constructor accepts queue example
- access head of underlying linked list
- traverse list, using elements populate queue, creating new nodes hold same values
Comments
Post a Comment