Java Code Examples for java.util.BitSet#previousSetBit()

The following examples show how to use java.util.BitSet#previousSetBit() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Label.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
private boolean isVariablePartitioningEqual(final Stack other, final int toSlot) {
    // No difference in the symbol boundaries before the toSlot
    final BitSet diff = other.getSymbolBoundaryCopy();
    diff.xor(symbolBoundary);
    return diff.previousSetBit(toSlot - 1) == -1;
}
 
Example 2
Source File: Label.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
private boolean isVariablePartitioningEqual(final Stack other, final int toSlot) {
    // No difference in the symbol boundaries before the toSlot
    final BitSet diff = other.getSymbolBoundaryCopy();
    diff.xor(symbolBoundary);
    return diff.previousSetBit(toSlot - 1) == -1;
}
 
Example 3
Source File: LunarExpression.java    From jstarcraft-core with Apache License 2.0 4 votes vote down vote up
@Override
public ZonedDateTime getPreviousDateTime(ZonedDateTime dateTime) {
    LunarDate lunar = new LunarDate(dateTime.toLocalDate());
    int year = lunar.getYear();
    boolean leap = lunar.isLeap();
    int month = lunar.getMonth();
    int day = lunar.getDay();
    int size = LunarDate.getDaySize(year, leap, month);
    BitSet days = getDays(size);
    LocalTime time = dateTime.toLocalTime();
    int hour = time.getHour();
    int minute = time.getMinute();
    int second = time.getSecond();
    second = seconds.previousSetBit(second - 1);
    if (second == -1) {
        second = seconds.previousSetBit(59);
        minute--;
    }
    minute = minutes.previousSetBit(minute);
    if (minute == -1) {
        second = seconds.previousSetBit(59);
        minute = minutes.previousSetBit(59);
        hour--;
    }
    hour = hours.previousSetBit(hour);
    if (hour == -1) {
        second = seconds.previousSetBit(59);
        minute = minutes.previousSetBit(59);
        hour = hours.previousSetBit(23);
        day--;
    }
    day = days.previousSetBit(day);
    if (day == -1) {
        second = seconds.previousSetBit(59);
        minute = minutes.previousSetBit(59);
        hour = hours.previousSetBit(23);
    }
    while (day == -1) {
        // 从是闰月到非闰月
        if (leap && month == LunarDate.getLeapMonth(year)) {
            leap = false;
        } else {
            month--;
            // 从非闰月到是闰月
            if (month == LunarDate.getLeapMonth(year)) {
                leap = true;
            }
        }
        // 月份是否变化
        if (!months.get(month)) {
            month = months.previousSetBit(month);
            if (month == -1) {
                month = months.previousSetBit(12);
                year--;
                year = years.previousSetBit(year - LunarDate.MINIMUM_YEAR);
                if (year == -1) {
                    return null;
                }
                year += LunarDate.MINIMUM_YEAR;
            }
            // 可能是闰月
            leap = month == LunarDate.getLeapMonth(year);
        }
        size = LunarDate.getDaySize(year, leap, month);
        days = getDays(size);
        day = days.previousSetBit(30);
    }
    if (!years.get(year - LunarDate.MINIMUM_YEAR)) {
        return null;
    }
    lunar = new LunarDate(year, leap, month, day);
    LocalDate date = lunar.getDate();
    return ZonedDateTime.of(date, LocalTime.of(hour, minute, second), dateTime.getZone());
}
 
Example 4
Source File: IslamicExpression.java    From jstarcraft-core with Apache License 2.0 4 votes vote down vote up
@Override
public ZonedDateTime getPreviousDateTime(ZonedDateTime dateTime) {
    IslamicDate islamic = new IslamicDate(dateTime.toLocalDate());
    int year = islamic.getYear();
    int month = islamic.getMonth();
    int day = islamic.getDay();
    int size = IslamicDate.getDaySize(year, month);
    BitSet days = getDays(size);
    LocalTime time = dateTime.toLocalTime();
    int hour = time.getHour();
    int minute = time.getMinute();
    int second = time.getSecond();
    second = seconds.previousSetBit(second - 1);
    if (second == -1) {
        second = seconds.previousSetBit(59);
        minute--;
    }
    minute = minutes.previousSetBit(minute);
    if (minute == -1) {
        second = seconds.previousSetBit(59);
        minute = minutes.previousSetBit(59);
        hour--;
    }
    hour = hours.previousSetBit(hour);
    if (hour == -1) {
        second = seconds.previousSetBit(59);
        minute = minutes.previousSetBit(59);
        hour = hours.previousSetBit(23);
        day--;
    }
    day = days.previousSetBit(day);
    if (day == -1) {
        second = seconds.previousSetBit(59);
        minute = minutes.previousSetBit(59);
        hour = hours.previousSetBit(23);
    }
    while (day == -1) {
        month--;
        if (!months.get(month)) {
            month = months.previousSetBit(month);
            if (month == -1) {
                month = months.previousSetBit(12);
                year--;
                year = years.previousSetBit(year - IslamicDate.MINIMUM_YEAR);
                if (year == -1) {
                    return null;
                }
                year += IslamicDate.MINIMUM_YEAR;
            }
        }
        size = IslamicDate.getDaySize(year, month);
        days = getDays(size);
        day = days.previousSetBit(30);
    }
    if (!years.get(year - IslamicDate.MINIMUM_YEAR)) {
        return null;
    }
    islamic = new IslamicDate(year, month, day);
    LocalDate date = islamic.getDate();
    return ZonedDateTime.of(date, LocalTime.of(hour, minute, second), dateTime.getZone());
}
 
Example 5
Source File: Label.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
private boolean isVariablePartitioningEqual(final Stack other, final int toSlot) {
    // No difference in the symbol boundaries before the toSlot
    final BitSet diff = other.getSymbolBoundaryCopy();
    diff.xor(symbolBoundary);
    return diff.previousSetBit(toSlot - 1) == -1;
}
 
Example 6
Source File: Label.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
private boolean isVariablePartitioningEqual(final Stack other, final int toSlot) {
    // No difference in the symbol boundaries before the toSlot
    final BitSet diff = other.getSymbolBoundaryCopy();
    diff.xor(symbolBoundary);
    return diff.previousSetBit(toSlot - 1) == -1;
}
 
Example 7
Source File: Label.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
private boolean isVariablePartitioningEqual(final Stack other, final int toSlot) {
    // No difference in the symbol boundaries before the toSlot
    final BitSet diff = other.getSymbolBoundaryCopy();
    diff.xor(symbolBoundary);
    return diff.previousSetBit(toSlot - 1) == -1;
}
 
Example 8
Source File: Label.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
private boolean isVariablePartitioningEqual(final Stack other, final int toSlot) {
    // No difference in the symbol boundaries before the toSlot
    final BitSet diff = other.getSymbolBoundaryCopy();
    diff.xor(symbolBoundary);
    return diff.previousSetBit(toSlot - 1) == -1;
}
 
Example 9
Source File: Label.java    From jdk8u_nashorn with GNU General Public License v2.0 4 votes vote down vote up
private boolean isVariablePartitioningEqual(final Stack other, final int toSlot) {
    // No difference in the symbol boundaries before the toSlot
    final BitSet diff = other.getSymbolBoundaryCopy();
    diff.xor(symbolBoundary);
    return diff.previousSetBit(toSlot - 1) == -1;
}