Show More
@@ -2320,14 +2320,16 b' class abstractsmartset(object):' | |||
|
2320 | 2320 | kwargs['ascending'] = False |
|
2321 | 2321 | return filteredset(self, condition, **kwargs) |
|
2322 | 2322 | |
|
2323 |
class baseset( |
|
|
2323 | class baseset(abstractsmartset): | |
|
2324 | 2324 | """Basic data structure that represents a revset and contains the basic |
|
2325 | 2325 | operation that it should be able to perform. |
|
2326 | 2326 | |
|
2327 | 2327 | Every method in this class should be implemented by any smartset class. |
|
2328 | 2328 | """ |
|
2329 | 2329 | def __init__(self, data=()): |
|
2330 | super(baseset, self).__init__(data) | |
|
2330 | if not isinstance(data, list): | |
|
2331 | data = list(data) | |
|
2332 | self._list = data | |
|
2331 | 2333 | self._set = None |
|
2332 | 2334 | |
|
2333 | 2335 | def set(self): |
@@ -2346,7 +2348,19 b' class baseset(list, abstractsmartset):' | |||
|
2346 | 2348 | return self.set().__contains__ |
|
2347 | 2349 | |
|
2348 | 2350 | def __nonzero__(self): |
|
2349 |
return bool( |
|
|
2351 | return bool(self._list) | |
|
2352 | ||
|
2353 | def sort(self, reverse=False): | |
|
2354 | self._list.sort(reverse=reverse) | |
|
2355 | ||
|
2356 | def reverse(self): | |
|
2357 | self._list.reverse() | |
|
2358 | ||
|
2359 | def __iter__(self): | |
|
2360 | return iter(self._list) | |
|
2361 | ||
|
2362 | def __len__(self): | |
|
2363 | return len(self._list) | |
|
2350 | 2364 | |
|
2351 | 2365 | def __sub__(self, other): |
|
2352 | 2366 | """Returns a new object with the substraction of the two collections. |
@@ -2389,12 +2403,12 b' class baseset(list, abstractsmartset):' | |||
|
2389 | 2403 | |
|
2390 | 2404 | def first(self): |
|
2391 | 2405 | if self: |
|
2392 | return self[0] | |
|
2406 | return self._list[0] | |
|
2393 | 2407 | return None |
|
2394 | 2408 | |
|
2395 | 2409 | def last(self): |
|
2396 | 2410 | if self: |
|
2397 | return self[-1] | |
|
2411 | return self._list[-1] | |
|
2398 | 2412 | return None |
|
2399 | 2413 | |
|
2400 | 2414 | class filteredset(abstractsmartset): |
General Comments 0
You need to be logged in to leave comments.
Login now