Reverse a doubly-linked queue in constant time

Hi everibody.Any ideas for a solution for reversing a queue, implemented as a doubly-linked list, in constant time ?
[130 byte] By [zef777a] at [2007-11-26 22:20:47]
# 1
Interchange the head and the tail?
ejpa at 2007-7-10 11:18:03 > top of Java-index,Java Essentials,Java Programming...
# 2

> Interchange the head and the tail?

That still leaves the middle section in the original order.

The only way I can think of to do it is if you have a direction member variable that's used to determine the orientation of head, tail, next() and prev().

Or wrap it in a decorator that delgates head() to tail(), next() to prev(), etc.

jverda at 2007-7-10 11:18:03 > top of Java-index,Java Essentials,Java Programming...
# 3
Hi, jverd.The direction variable seems a very good idea. I am going to try it and will let You know.Thanks
zef777a at 2007-7-10 11:18:03 > top of Java-index,Java Essentials,Java Programming...