| 1090 | } |
| 1091 | |
| 1092 | unsigned char *zzlDeleteRangeByScore(unsigned char *zl, zrangespec *range, unsigned long *deleted) { |
| 1093 | unsigned char *eptr, *sptr; |
| 1094 | double score; |
| 1095 | unsigned long num = 0; |
| 1096 | |
| 1097 | if (deleted != NULL) *deleted = 0; |
| 1098 | |
| 1099 | eptr = zzlFirstInRange(zl,range); |
| 1100 | if (eptr == NULL) return zl; |
| 1101 | |
| 1102 | /* When the tail of the ziplist is deleted, eptr will point to the sentinel |
| 1103 | * byte and ziplistNext will return NULL. */ |
| 1104 | while ((sptr = ziplistNext(zl,eptr)) != NULL) { |
| 1105 | score = zzlGetScore(sptr); |
| 1106 | if (zslValueLteMax(score,range)) { |
| 1107 | /* Delete both the element and the score. */ |
| 1108 | zl = ziplistDelete(zl,&eptr); |
| 1109 | zl = ziplistDelete(zl,&eptr); |
| 1110 | num++; |
| 1111 | } else { |
| 1112 | /* No longer in range. */ |
| 1113 | break; |
| 1114 | } |
| 1115 | } |
| 1116 | |
| 1117 | if (deleted != NULL) *deleted = num; |
| 1118 | return zl; |
| 1119 | } |
| 1120 | |
| 1121 | unsigned char *zzlDeleteRangeByLex(unsigned char *zl, zlexrangespec *range, unsigned long *deleted) { |
| 1122 | unsigned char *eptr, *sptr; |
no test coverage detected