下面列出了java.util.BitSet#previousSetBit ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
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;
}
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;
}
@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());
}
@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());
}
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;
}
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;
}
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;
}
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;
}
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;
}