![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Modularizando o src
Dependencies: EALib EthernetInterface_vz mbed-rtos mbed
Fork of header_main_colinas_V0-20-09-14 by
vector.h@121:ee02790d00b7, 2015-05-08 (annotated)
- Committer:
- klauss
- Date:
- Fri May 08 04:15:23 2015 +0000
- Revision:
- 121:ee02790d00b7
- Parent:
- 114:472502b31a12
- Child:
- 135:2f4290590e51
compiling
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
klauss | 69:65665afbad5d | 1 | /** |
klauss | 69:65665afbad5d | 2 | * @file vector.h |
klauss | 69:65665afbad5d | 3 | * @Synopsis A classe Vector representa uma lista de Objects. O objetivo dessa classe é manter de forma organizada na memória as |
klauss | 69:65665afbad5d | 4 | * instâncias da classe Object. |
klauss | 69:65665afbad5d | 5 | * @author Jhonatan Casale |
klauss | 69:65665afbad5d | 6 | * @version 1 |
klauss | 69:65665afbad5d | 7 | * @date 2014-10-31 |
klauss | 69:65665afbad5d | 8 | * \class Vector |
klauss | 69:65665afbad5d | 9 | * \note Não preserva ordem dos seus elementos. |
klauss | 69:65665afbad5d | 10 | */ |
klauss | 69:65665afbad5d | 11 | |
klauss | 0:4d17cd9c8f9d | 12 | #ifndef __VECTOR_H__ |
klauss | 0:4d17cd9c8f9d | 13 | #define __VECTOR_H__ |
klauss | 0:4d17cd9c8f9d | 14 | |
klauss | 121:ee02790d00b7 | 15 | #include "mbed.h" |
klauss | 0:4d17cd9c8f9d | 16 | #include <stdlib.h> |
klauss | 0:4d17cd9c8f9d | 17 | #include "object.h" |
klauss | 4:de46f0d9b14d | 18 | #include "debug.h" |
klauss | 0:4d17cd9c8f9d | 19 | |
klauss | 0:4d17cd9c8f9d | 20 | class Vector{ |
klauss | 0:4d17cd9c8f9d | 21 | private: |
klauss | 0:4d17cd9c8f9d | 22 | Object **objects; |
klauss | 0:4d17cd9c8f9d | 23 | int elements; |
klauss | 0:4d17cd9c8f9d | 24 | |
klauss | 0:4d17cd9c8f9d | 25 | public: |
klauss | 69:65665afbad5d | 26 | /** |
klauss | 69:65665afbad5d | 27 | * Cria um objeto do tipo vetor pronto para uso. |
klauss | 69:65665afbad5d | 28 | * |
klauss | 69:65665afbad5d | 29 | * Exemplo: |
klauss | 69:65665afbad5d | 30 | * @code |
klauss | 69:65665afbad5d | 31 | * ... |
klauss | 69:65665afbad5d | 32 | * Vector * v = new Vector(); |
klauss | 69:65665afbad5d | 33 | * ... |
klauss | 69:65665afbad5d | 34 | * @endcode |
klauss | 69:65665afbad5d | 35 | */ |
klauss | 0:4d17cd9c8f9d | 36 | Vector(); |
klauss | 69:65665afbad5d | 37 | |
klauss | 69:65665afbad5d | 38 | /** |
klauss | 69:65665afbad5d | 39 | * Deleta todos os elementos do vetor |
klauss | 69:65665afbad5d | 40 | * \note Preserva os elementos originais |
klauss | 69:65665afbad5d | 41 | */ |
klauss | 0:4d17cd9c8f9d | 42 | ~Vector(); |
klauss | 69:65665afbad5d | 43 | |
klauss | 69:65665afbad5d | 44 | /** |
klauss | 69:65665afbad5d | 45 | * @Synopsis Adiciona o elemento @f$e@f$ ao final do vetor |
klauss | 69:65665afbad5d | 46 | * |
klauss | 69:65665afbad5d | 47 | * @param e Um ponteiro para algum objeto da clase Object |
klauss | 69:65665afbad5d | 48 | * |
klauss | 69:65665afbad5d | 49 | * Exemplo: |
klauss | 69:65665afbad5d | 50 | * @code |
klauss | 69:65665afbad5d | 51 | * ... |
klauss | 69:65665afbad5d | 52 | * v->add( new * Object ); |
klauss | 69:65665afbad5d | 53 | * ... |
klauss | 69:65665afbad5d | 54 | * @endcode |
klauss | 69:65665afbad5d | 55 | */ |
klauss | 0:4d17cd9c8f9d | 56 | void add( Object * e ); |
klauss | 69:65665afbad5d | 57 | |
klauss | 69:65665afbad5d | 58 | /** |
klauss | 69:65665afbad5d | 59 | * @Synopsis Retorna elementos contidos no vetor |
klauss | 69:65665afbad5d | 60 | * |
klauss | 69:65665afbad5d | 61 | * @param position A posicao do elemento de interesse |
klauss | 69:65665afbad5d | 62 | * |
klauss | 69:65665afbad5d | 63 | * @return Um objeto da classe Object caso position seja |
klauss | 69:65665afbad5d | 64 | * maior do que zero e menor que o numero de elementos |
klauss | 69:65665afbad5d | 65 | * do vetor, NULL caso contrario |
klauss | 69:65665afbad5d | 66 | * |
klauss | 69:65665afbad5d | 67 | * Exemplo: |
klauss | 69:65665afbad5d | 68 | * @code |
klauss | 69:65665afbad5d | 69 | * ... |
klauss | 69:65665afbad5d | 70 | * Object obj = v->get_element( 0x01 ); |
klauss | 69:65665afbad5d | 71 | * ... |
klauss | 69:65665afbad5d | 72 | * @endcode |
klauss | 69:65665afbad5d | 73 | */ |
klauss | 0:4d17cd9c8f9d | 74 | Object * get_element( int position ); |
klauss | 69:65665afbad5d | 75 | |
klauss | 69:65665afbad5d | 76 | /** |
klauss | 69:65665afbad5d | 77 | * @Synopsis Remove elementos contidos no vetor |
klauss | 69:65665afbad5d | 78 | * |
klauss | 69:65665afbad5d | 79 | * @param position Remove o elemento na posição position, |
klauss | 69:65665afbad5d | 80 | * desde de, position seja maior do que 0 e menor do que o |
klauss | 69:65665afbad5d | 81 | * numero de elementos do vetor. |
klauss | 69:65665afbad5d | 82 | * |
klauss | 69:65665afbad5d | 83 | */ |
klauss | 0:4d17cd9c8f9d | 84 | void remove_element( int position ); |
klauss | 69:65665afbad5d | 85 | |
klauss | 69:65665afbad5d | 86 | /** |
klauss | 69:65665afbad5d | 87 | * @Synopsis Executa procedimento de busca nos elementos do vetor |
klauss | 69:65665afbad5d | 88 | * |
klauss | 69:65665afbad5d | 89 | * @param e Verifica se o elemento @f$e@f$ esta contido no vetor |
klauss | 69:65665afbad5d | 90 | * |
klauss | 69:65665afbad5d | 91 | * @return Um inteiro maior ou igual a zero caso o elemento estiver |
klauss | 69:65665afbad5d | 92 | * contido no vetor, -3 caso o elemento ainda nao pertença. |
klauss | 69:65665afbad5d | 93 | * |
klauss | 69:65665afbad5d | 94 | * Exemplo: |
klauss | 69:65665afbad5d | 95 | * @code |
klauss | 69:65665afbad5d | 96 | * ... |
klauss | 69:65665afbad5d | 97 | * Object * obj = new Obj(); |
klauss | 69:65665afbad5d | 98 | * return( v->find_element( e ) ); |
klauss | 69:65665afbad5d | 99 | * ... |
klauss | 69:65665afbad5d | 100 | * @endcode |
klauss | 69:65665afbad5d | 101 | */ |
klauss | 0:4d17cd9c8f9d | 102 | int find_element( Object * e ); |
klauss | 69:65665afbad5d | 103 | |
klauss | 69:65665afbad5d | 104 | /** |
klauss | 69:65665afbad5d | 105 | * @Synopsis Executa procedimento de busca nos elementos do vetor |
klauss | 69:65665afbad5d | 106 | * |
klauss | 69:65665afbad5d | 107 | * @param ext Verifica se existe algum elemento com este ramal contido no vetor |
klauss | 69:65665afbad5d | 108 | * @param port Verifica se existe algum elemento com esta porta contido no vetor |
klauss | 69:65665afbad5d | 109 | * \note Este método não esta completamente implementado. |
klauss | 69:65665afbad5d | 110 | * |
klauss | 69:65665afbad5d | 111 | * @return Um ponteiro para o objeto de interesse. NULL, caso este objeto não tenha |
klauss | 69:65665afbad5d | 112 | * sido encontrado. |
klauss | 69:65665afbad5d | 113 | * |
klauss | 69:65665afbad5d | 114 | * Exemplo: |
klauss | 69:65665afbad5d | 115 | * @code |
klauss | 69:65665afbad5d | 116 | * ... |
klauss | 69:65665afbad5d | 117 | * return( find_element( 1011, 1011 ); |
klauss | 69:65665afbad5d | 118 | * ... |
klauss | 69:65665afbad5d | 119 | * @endcode |
klauss | 69:65665afbad5d | 120 | */ |
klauss | 0:4d17cd9c8f9d | 121 | Object * find_element( int ext, int port ); |
klauss | 69:65665afbad5d | 122 | |
klauss | 69:65665afbad5d | 123 | /** |
klauss | 69:65665afbad5d | 124 | * @Synopsis Representa o numero de elementos contidos no vetor. |
klauss | 69:65665afbad5d | 125 | * |
klauss | 69:65665afbad5d | 126 | * @return O numero de elementos contidos no vetor |
klauss | 69:65665afbad5d | 127 | * |
klauss | 69:65665afbad5d | 128 | * Exemplo: |
klauss | 69:65665afbad5d | 129 | * @code |
klauss | 69:65665afbad5d | 130 | * ... |
klauss | 69:65665afbad5d | 131 | * v->size(); |
klauss | 69:65665afbad5d | 132 | * ... |
klauss | 69:65665afbad5d | 133 | * @endcode |
klauss | 69:65665afbad5d | 134 | */ |
klauss | 121:ee02790d00b7 | 135 | int size ( void ); |
klauss | 114:472502b31a12 | 136 | int print_yourself ( void ); |
klauss | 0:4d17cd9c8f9d | 137 | }; |
klauss | 0:4d17cd9c8f9d | 138 | #endif |