@SuppressWarnings("unchecked")
	public ArrayList<String> zRange(String key, int startIndex, int endIndex, boolean withScores)
	{
		ArrayList<String> result = new ArrayList<String>();
		
		if(zMemberMap.containsKey(key))
		{
			TreeSet<MemberScore> set = zMemberMap.get(key);
			int size = set.size();
			if(startIndex < 0) //calculating the actual index in case of relative negative index.
			{
				startIndex = size - startIndex;
			}
			if(endIndex < 0)
			{
				endIndex = size + endIndex;
			}
			if(startIndex > endIndex)
			{
				result.add("(empty list or set)");
				return result;
			}
			else
			{
				Iterator<MemberScore> iter = set.iterator();
				int count = 0;
				// Reach to the start element in the range.
				while(iter.hasNext())
				{
					if(startIndex == count)
					{
						break;
					}
					iter = (Iterator<MemberScore>) iter.next();
					count++;
				}
				
				
				while(iter.hasNext() && count <= endIndex)
				{
					MemberScore memberScore = iter.next();
					result.add(memberScore.getMember());
					if(withScores)
					{
						result.add(memberScore.getScore().toString());
					}
					count++;
				}
			}
		}
		else
		{
			result.add("(empty list or set)");
		}
		return result;
	}