mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-22 21:09:21 +00:00
34 lines
633 B
Dart
34 lines
633 B
Dart
|
import 'dart:collection';
|
||
|
|
||
|
import 'package:comunic/models/user.dart';
|
||
|
|
||
|
/// Users list
|
||
|
///
|
||
|
/// @author Pierre HUBERT
|
||
|
|
||
|
class UsersList extends ListBase<User> {
|
||
|
|
||
|
List<User> _list = List();
|
||
|
|
||
|
int get length => _list.length;
|
||
|
set length(l) => _list.length = l;
|
||
|
|
||
|
@override
|
||
|
User operator [](int index) {
|
||
|
return _list[index];
|
||
|
}
|
||
|
|
||
|
@override
|
||
|
void operator []=(int index, User value) {
|
||
|
_list[index] = value;
|
||
|
}
|
||
|
|
||
|
/// Find a user with a specific ID
|
||
|
User getUser(int userID){
|
||
|
for(int i = 0; i < this.length; i++)
|
||
|
if(this[i].id == userID)
|
||
|
return this[i];
|
||
|
|
||
|
throw "User not found in the list!";
|
||
|
}
|
||
|
}
|