Wither Well
Wither Well
JCHJava Community | Help. Code. Learn.
Created by Wither Well on 3/29/2025 in #java-help
Stack Interface, Deque Implementation: Worth it?
Thanks again for your help
33 replies
JCHJava Community | Help. Code. Learn.
Created by Wither Well on 3/29/2025 in #java-help
Stack Interface, Deque Implementation: Worth it?
I will link the articles in case someone visits this post and wants to read
33 replies
JCHJava Community | Help. Code. Learn.
Created by Wither Well on 3/29/2025 in #java-help
Stack Interface, Deque Implementation: Worth it?
Right, I understand. Well, that's all. Thank you very much for your help!
33 replies
JCHJava Community | Help. Code. Learn.
Created by Wither Well on 3/29/2025 in #java-help
Stack Interface, Deque Implementation: Worth it?
So it would not be necessary to try to implement a strict LIFO contract right? Like, the whole thing about "Does not maintain strict LIFO contract" feels like a non-issue. Is it fair that's how I feel about this?
33 replies
JCHJava Community | Help. Code. Learn.
Created by Wither Well on 3/29/2025 in #java-help
Stack Interface, Deque Implementation: Worth it?
No problem, I should have been clear!
33 replies
JCHJava Community | Help. Code. Learn.
Created by Wither Well on 3/29/2025 in #java-help
Stack Interface, Deque Implementation: Worth it?
I just do not quite understand why being so strict about LIFO contract is really critical and was wondering if there were instances where that would be important.
33 replies
JCHJava Community | Help. Code. Learn.
Created by Wither Well on 3/29/2025 in #java-help
Stack Interface, Deque Implementation: Worth it?
There were two articles I read that complained about both Stack and Deque not strictly maintaining LIFO contract, and both offered the solution I showed above (defining a Stack interface and implementing it). I was just wondering why that would be an issue. If an ArrayDeque is functionally used as a Stack, so technically showing a LIFO behavior, would it be an issue if it still has certain methods that would allow it to break LIFO contract?
33 replies
JCHJava Community | Help. Code. Learn.
Created by Wither Well on 3/29/2025 in #java-help
Stack Interface, Deque Implementation: Worth it?
Ah, right. Yeah, I had checked the rules and was unsure what the problem is. Thanks! Would you perhaps like if I still link the articles?
33 replies
JCHJava Community | Help. Code. Learn.
Created by Wither Well on 3/29/2025 in #java-help
Stack Interface, Deque Implementation: Worth it?
I am sorry but I am unsure what you mean by "masked links".
33 replies
JCHJava Community | Help. Code. Learn.
Created by Wither Well on 3/29/2025 in #java-help
Stack Interface, Deque Implementation: Worth it?
I am more so questioning the point of creating such a solution rather than whether I myself should use such solution. I am curious about it because I have seen two articles/posts regarding Java's Stack and simply wondered, "why"?
33 replies
JCHJava Community | Help. Code. Learn.
Created by Wither Well on 3/29/2025 in #java-help
Stack Interface, Deque Implementation: Worth it?
Stack class inherits from Vector class which has methods such as indexOf(), elementAt(), setElementAt(), insertElementAt() which are methods that allows indexed access, this breaks LIFO contract. The Java API for Stack class encourages the usage of Deque over Stack. However, I am not trying to discuss the validity of Stack class as a LIFO object. Instead, I am trying to discuss why such solutions have been made in the first place (I have not created this solution myself, I found them online). As indicated by the title; is it worth it to have such solutions?
33 replies