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

  • Home
  • SEARCH
  • 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 1014457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T10:15:24+00:00 2026-05-16T10:15:24+00:00

I have Grid which will render a calendar, and I’m provided with an ArrayList<CalendarEventEntity>

  • 0

I have Grid which will render a calendar, and I’m provided with an ArrayList<CalendarEventEntity> which contains events. Those events have to be highlighted in the grid.

As I have to fill the grid by my self I have something like this:

for( loop through the days of the month ){
    Calendar eventDate = event.getDate();
    // look for the events in the calendar that matchs this day
    for(CalendarEventEntity event : events) {
        // if there are events in this specific day
        if( eventDate.get(Calendar.YEAR) == calendarMonth.get(Calendar.YEAR) &&
            eventDate.get(Calendar.MONTH) == calendarMonth.get(Calendar.MONTH) &&
            eventDate.get(Calendar.DAY_OF_MONTH) == dayIndex ) {
            // highlight it!!!
        }
    }

}

This works fine, but it’s too slow. So I want to speed it up! I added this before the inner for:

// ignore dates which does not make part of this month or year
if( eventDate.get(Calendar.YEAR) < calendarMonth.get(Calendar.YEAR) ||
    eventDate.get(Calendar.MONTH) < calendarMonth.get(Calendar.MONTH) ||
    eventDate.get(Calendar.DAY_OF_MONTH) != DateIdx ) {
    continue;
}

// stop when processing dates which are higher than this month or year
if( eventDate.get(Calendar.YEAR) > calendarMonth.get(Calendar.YEAR) ||
    eventDate.get(Calendar.MONTH) > calendarMonth.get(Calendar.MONTH) 
    || eventDate.get(Calendar.DAY_OF_MONTH) != DateIdx ) {
    break;
}

and that made if faster, but it’s still too slow. How can I improve this algorithm?

  • 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-05-16T10:15:24+00:00Added an answer on May 16, 2026 at 10:15 am

    The problem is that each day you have to search every event looking for events on that date. You need to find a way to only be searching through events on that day, or to know if events are on that day at all.

    You should consider using a HashMap to store your events indexed by date. Then you can just check to see if there’s a HashMap entry for the day in question. You’ll have to pick a way to represent a day that would be universal enough to be used as a key.

    This will also be handy when you have to drill down into the details of one specific day and show only the events on that day. You shouldn’t have to search through all events every time you want to find events for one specific day.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Grid which contains an Image in one of its columns. The
I have a grid view which contains a button in a template field. I
In my project I have a grid view which contains images. Based on my
I have two grid rows which will vary in terms of the content of
I need to create my own grid which will have customized paging and sorting.
I have grid view which contains five radio buttons per row. Out of these
In my selenium grid setup, I have to execute 2 modules initially, which will
I have a grid which I would like to show extra information with RowExpander
I have a grid which has 4 bands and the columns in band[3] are
I have a Telerik Grid which has a footer that needs to display column

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.