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:

  1. write constructor accepts queue example
  2. access head of underlying linked list
  3. traverse list, using elements populate queue, creating new nodes hold same values

Comments

Popular posts from this blog

node.js - How to mock a third-party api calls in the backend -

node.js - Why do I get "SOCKS connection failed. Connection not allowed by ruleset" for some .onion sites? -

matlab - 0-by-1 sym - What do I need to change in order to get proper symbolic results? -