Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7915195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T14:22:39+00:00 2026-06-03T14:22:39+00:00

I need some advice how to implement this situation in my application. I have

  • 0

I need some advice how to implement this situation in my application.

I have array of bitmpaps, which I’m using to store different states of my Canvas, so I can use them in the future. Here is the code which I’m using :

private Bitmap[] temp;
// on user click happens this ->
if(index<5){
            temp[index] = Bitmap.createBitmap(mBitmap);
            index++;
}

So basically I want to save only the last 5 bitmaps depending on user’s actions. The things which I want to learn is how can I update my array so I can always have the last 5 bitmaps.

Here is what I mean :

Bitmaps [1,2,3,4,5] -> after user clicks I want to delete the first bitmap, re-order the array and save the new one as the last..so my array should look like this : Bitmaps[2,3,4,5,6];

Any suggestions / advices which is the best way to do that?

Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T14:22:40+00:00Added an answer on June 3, 2026 at 2:22 pm

    I just wrote this…
    Use this code to initialise:

    Cacher cach = new Cacher(5);
    //when you want to add a bitmap
    cach.add(yourBitmap);
    //get the i'th bitmap using
    cach.get(yourIndex);
    

    Remember you can re implement the function get to return the ith “old” Bitmap

    public class Cacher {
        public Cacher(int max) {
    
            this.max = max;
            temp = new Bitmap[max];
            time = new long[max];
            for(int i=0;i<max;i++)
                time[i] = -1;
        }
        private Bitmap[] temp;
        private long[] time;
        private int max = 5;
        public void add(Bitmap mBitmap) {
            int index = getIndexForNew();
            temp[index] = Bitmap.createBitmap(mBitmap);
    
        }
        public Bitmap get(int i) {
            if(time[i] == -1)
                return null;
            else
                return temp[i];
        }
        private int getIndexForNew() {
            int minimum = 0;
            long value = time[minimum];
            for(int i=0;i<max;i++) {
                if(time[i]==-1)
                    return i;
                else {
                    if(time[i]<value) {
                        minimum = i;
                        value = time[minimum];
                    }
            }
            return minimum;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need some advice from experts :) I will develop a website using PHP
I need some advice on techniques to perform page redirect in asp.net. Which one
I need some advice in creating and ordering indexes in mongo. I have a
Experts - I need some advice in the following scenario. I have a configuration
I just need some advice on if this is wise. I'm loading my site
I need some LINQ advice (or even general advice) on how to implement the
i need an advice on how to implement my form. I have a requirement:
I'm tinkering with Akka and need some advice how to implement something specific i
I need some advice on the implementation of the Dispose method. In our application
I need some advice on what kind of pattern(s) I should use for pushing/pulling

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.