trie.hh (8959:24b06cbf2d67) trie.hh (12332:2adbc3f0f65a)
1/*
2 * Copyright (c) 2012 Google
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;

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

180 * @param key The key which can later be used to look up this value.
181 * @param width How many bits of the key (from msb) should be used.
182 * @param val A pointer to the value to store in the trie.
183 * @return A Handle corresponding to this value.
184 */
185 Handle
186 insert(Key key, unsigned width, Value *val)
187 {
1/*
2 * Copyright (c) 2012 Google
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;

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

180 * @param key The key which can later be used to look up this value.
181 * @param width How many bits of the key (from msb) should be used.
182 * @param val A pointer to the value to store in the trie.
183 * @return A Handle corresponding to this value.
184 */
185 Handle
186 insert(Key key, unsigned width, Value *val)
187 {
188 // We use NULL value pointers to mark internal nodes of the trie, so
189 // we don't allow inserting them as real values.
190 assert(val);
191
188 // Build a mask which masks off all the bits we don't care about.
189 Key new_mask = ~(Key)0;
190 if (width < MaxBits)
191 new_mask <<= (MaxBits - width);
192 // Use it to tidy up the key.
193 key &= new_mask;
194
195 // Walk past all the nodes this new node will be inserted after. They

--- 165 unchanged lines hidden ---
192 // Build a mask which masks off all the bits we don't care about.
193 Key new_mask = ~(Key)0;
194 if (width < MaxBits)
195 new_mask <<= (MaxBits - width);
196 // Use it to tidy up the key.
197 key &= new_mask;
198
199 // Walk past all the nodes this new node will be inserted after. They

--- 165 unchanged lines hidden ---