Deleted Added
sdiff udiff text old ( 7813:7338bc628489 ) new ( 10200:1ab8753de4d8 )
full compact
1/*
2 * Copyright (c) 2004-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 35 unchanged lines hidden (view full) ---

44 int future;
45 unsigned size;
46 int _id;
47
48 char *data;
49 std::vector<char *> index;
50 unsigned base;
51
52 void valid(int idx)
53 {
54 assert (idx >= -past && idx <= future);
55 }
56
57 public:
58 friend class wire;
59 class wire
60 {

--- 123 unchanged lines hidden (view full) ---

184 int ptr = base + future;
185 if (ptr >= (int)size)
186 ptr -= size;
187 (reinterpret_cast<T *>(index[ptr]))->~T();
188 std::memset(index[ptr], 0, sizeof(T));
189 new (index[ptr]) T;
190 }
191
192 T *access(int idx)
193 {
194 //Need more complex math here to calculate index.
195 valid(idx);
196
197 int vector_index = idx + base;
198 if (vector_index >= (int)size) {
199 vector_index -= size;
200 } else if (vector_index < 0) {
201 vector_index += size;
202 }
203
204 return reinterpret_cast<T *>(index[vector_index]);
205 }
206
207 T &operator[](int idx)
208 {
209 //Need more complex math here to calculate index.
210 valid(idx);
211
212 int vector_index = idx + base;
213 if (vector_index >= (int)size) {
214 vector_index -= size;
215 } else if (vector_index < 0) {
216 vector_index += size;
217 }
218
219 return reinterpret_cast<T &>(*index[vector_index]);
220 }
221
222 wire getWire(int idx)
223 {
224 valid(idx);
225
226 return wire(this, idx);
227 }
228
229 wire zero()

--- 12 unchanged lines hidden ---