Find pointer to the first element contained in the specified range. * Returns NULL when no element is contained in the range. */
| 853 | /* Find pointer to the first element contained in the specified range. |
| 854 | * Returns NULL when no element is contained in the range. */ |
| 855 | unsigned char *zzlFirstInRange(unsigned char *zl, zrangespec *range) { |
| 856 | unsigned char *eptr = ziplistIndex(zl,0), *sptr; |
| 857 | double score; |
| 858 | |
| 859 | /* If everything is out of range, return early. */ |
| 860 | if (!zzlIsInRange(zl,range)) return NULL; |
| 861 | |
| 862 | while (eptr != NULL) { |
| 863 | sptr = ziplistNext(zl,eptr); |
| 864 | serverAssert(sptr != NULL); |
| 865 | |
| 866 | score = zzlGetScore(sptr); |
| 867 | if (zslValueGteMin(score,range)) { |
| 868 | /* Check if score <= max. */ |
| 869 | if (zslValueLteMax(score,range)) |
| 870 | return eptr; |
| 871 | return NULL; |
| 872 | } |
| 873 | |
| 874 | /* Move to next element. */ |
| 875 | eptr = ziplistNext(zl,sptr); |
| 876 | } |
| 877 | |
| 878 | return NULL; |
| 879 | } |
| 880 | |
| 881 | /* Find pointer to the last element contained in the specified range. |
| 882 | * Returns NULL when no element is contained in the range. */ |
no test coverage detected