In java, which LIFO data structure class allows me to specify a MAX item size which automatically discards old items whenever adding an item will cause it to exceed MAX size.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can subclass
Stackto get the desired behavior. You just need to overridepush()to check whether the size is greater than N, and discard old items:will probably be close to what you want.