LinkedListMultimap.java 14.9 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670
package com.google.common.collect;

import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.base.Preconditions;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.AbstractSequentialList;
import java.util.Collection;
import java.util.Collections;
import java.util.ConcurrentModificationException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import javax.annotation.Nullable;
import mw;
import mx;
import qh;

@GwtCompatible(emulated=true, serializable=true)
public class LinkedListMultimap<K, V>
  extends mx<K, V>
  implements ListMultimap<K, V>, Serializable
{
  @GwtIncompatible("java serialization not supported")
  private static final long serialVersionUID = 0L;
  private transient c<K, V> a;
  private transient c<K, V> b;
  private transient Map<K, b<K, V>> c;
  private transient int d;
  private transient int e;
  
  LinkedListMultimap()
  {
    this.c = Maps.newHashMap();
  }
  
  private LinkedListMultimap(int paramInt)
  {
    this.c = new HashMap(paramInt);
  }
  
  private LinkedListMultimap(Multimap<? extends K, ? extends V> paramMultimap)
  {
    this(paramMultimap.keySet().size());
    putAll(paramMultimap);
  }
  
  private c<K, V> a(@Nullable K paramK, @Nullable V paramV, @Nullable c<K, V> paramc)
  {
    paramV = new c(paramK, paramV);
    if (this.a == null)
    {
      this.b = paramV;
      this.a = paramV;
      this.c.put(paramK, new b(paramV));
      this.e += 1;
    }
    for (;;)
    {
      this.d += 1;
      return paramV;
      if (paramc != null) {
        break;
      }
      this.b.c = paramV;
      paramV.d = this.b;
      this.b = paramV;
      paramc = (b)this.c.get(paramK);
      if (paramc == null)
      {
        this.c.put(paramK, new b(paramV));
        this.e += 1;
      }
      else
      {
        paramc.c += 1;
        paramK = paramc.b;
        paramK.e = paramV;
        paramV.f = paramK;
        paramc.b = paramV;
      }
    }
    b localb = (b)this.c.get(paramK);
    localb.c += 1;
    paramV.d = paramc.d;
    paramV.f = paramc.f;
    paramV.c = paramc;
    paramV.e = paramc;
    if (paramc.f == null)
    {
      ((b)this.c.get(paramK)).a = paramV;
      label253:
      if (paramc.d != null) {
        break label289;
      }
      this.a = paramV;
    }
    for (;;)
    {
      paramc.d = paramV;
      paramc.f = paramV;
      break;
      paramc.f.e = paramV;
      break label253;
      label289:
      paramc.d.c = paramV;
    }
  }
  
  private void b(@Nullable Object paramObject)
  {
    Iterators.b(new e(paramObject));
  }
  
  private List<V> c(@Nullable Object paramObject)
  {
    return Collections.unmodifiableList(Lists.newArrayList(new e(paramObject)));
  }
  
  public static <K, V> LinkedListMultimap<K, V> create()
  {
    return new LinkedListMultimap();
  }
  
  public static <K, V> LinkedListMultimap<K, V> create(int paramInt)
  {
    return new LinkedListMultimap(paramInt);
  }
  
  public static <K, V> LinkedListMultimap<K, V> create(Multimap<? extends K, ? extends V> paramMultimap)
  {
    return new LinkedListMultimap(paramMultimap);
  }
  
  @GwtIncompatible("java.io.ObjectInputStream")
  private void readObject(ObjectInputStream paramObjectInputStream)
    throws IOException, ClassNotFoundException
  {
    paramObjectInputStream.defaultReadObject();
    this.c = Maps.newLinkedHashMap();
    int j = paramObjectInputStream.readInt();
    int i = 0;
    while (i < j)
    {
      put(paramObjectInputStream.readObject(), paramObjectInputStream.readObject());
      i += 1;
    }
  }
  
  @GwtIncompatible("java.io.ObjectOutputStream")
  private void writeObject(ObjectOutputStream paramObjectOutputStream)
    throws IOException
  {
    paramObjectOutputStream.defaultWriteObject();
    paramObjectOutputStream.writeInt(size());
    Iterator localIterator = entries().iterator();
    while (localIterator.hasNext())
    {
      Map.Entry localEntry = (Map.Entry)localIterator.next();
      paramObjectOutputStream.writeObject(localEntry.getKey());
      paramObjectOutputStream.writeObject(localEntry.getValue());
    }
  }
  
  public void clear()
  {
    this.a = null;
    this.b = null;
    this.c.clear();
    this.d = 0;
    this.e += 1;
  }
  
  public boolean containsKey(@Nullable Object paramObject)
  {
    return this.c.containsKey(paramObject);
  }
  
  public boolean containsValue(@Nullable Object paramObject)
  {
    return values().contains(paramObject);
  }
  
  final Set<K> e()
  {
    new Sets.f()
    {
      public final boolean contains(Object paramAnonymousObject)
      {
        return LinkedListMultimap.this.containsKey(paramAnonymousObject);
      }
      
      public final Iterator<K> iterator()
      {
        return new LinkedListMultimap.a(LinkedListMultimap.this, (byte)0);
      }
      
      public final boolean remove(Object paramAnonymousObject)
      {
        return !LinkedListMultimap.this.removeAll(paramAnonymousObject).isEmpty();
      }
      
      public final int size()
      {
        return LinkedListMultimap.d(LinkedListMultimap.this).size();
      }
    };
  }
  
  public List<Map.Entry<K, V>> entries()
  {
    return (List)super.entries();
  }
  
  final Iterator<Map.Entry<K, V>> g()
  {
    throw new AssertionError("should never be called");
  }
  
  public List<V> get(@Nullable final K paramK)
  {
    new AbstractSequentialList()
    {
      public final ListIterator<V> listIterator(int paramAnonymousInt)
      {
        return new LinkedListMultimap.e(LinkedListMultimap.this, paramK, paramAnonymousInt);
      }
      
      public final int size()
      {
        LinkedListMultimap.b localb = (LinkedListMultimap.b)LinkedListMultimap.d(LinkedListMultimap.this).get(paramK);
        if (localb == null) {
          return 0;
        }
        return localb.c;
      }
    };
  }
  
  final Map<K, Collection<V>> h()
  {
    return new Multimaps.a(this);
  }
  
  public boolean isEmpty()
  {
    return this.a == null;
  }
  
  public boolean put(@Nullable K paramK, @Nullable V paramV)
  {
    a(paramK, paramV, null);
    return true;
  }
  
  public List<V> removeAll(@Nullable Object paramObject)
  {
    List localList = c(paramObject);
    b(paramObject);
    return localList;
  }
  
  public List<V> replaceValues(@Nullable K paramK, Iterable<? extends V> paramIterable)
  {
    List localList = c(paramK);
    paramK = new e(paramK);
    paramIterable = paramIterable.iterator();
    while ((paramK.hasNext()) && (paramIterable.hasNext()))
    {
      paramK.next();
      paramK.set(paramIterable.next());
    }
    while (paramK.hasNext())
    {
      paramK.next();
      paramK.remove();
    }
    while (paramIterable.hasNext()) {
      paramK.add(paramIterable.next());
    }
    return localList;
  }
  
  public int size()
  {
    return this.d;
  }
  
  public List<V> values()
  {
    return (List)super.values();
  }
  
  final class a
    implements Iterator<K>
  {
    final Set<K> a = Sets.newHashSetWithExpectedSize(LinkedListMultimap.this.keySet().size());
    LinkedListMultimap.c<K, V> b = LinkedListMultimap.c(LinkedListMultimap.this);
    LinkedListMultimap.c<K, V> c;
    int d = LinkedListMultimap.a(LinkedListMultimap.this);
    
    private a() {}
    
    private void a()
    {
      if (LinkedListMultimap.a(LinkedListMultimap.this) != this.d) {
        throw new ConcurrentModificationException();
      }
    }
    
    public final boolean hasNext()
    {
      a();
      return this.b != null;
    }
    
    public final K next()
    {
      a();
      LinkedListMultimap.a(this.b);
      this.c = this.b;
      this.a.add(this.c.a);
      do
      {
        this.b = this.b.c;
      } while ((this.b != null) && (!this.a.add(this.b.a)));
      return (K)this.c.a;
    }
    
    public final void remove()
    {
      a();
      if (this.c != null) {}
      for (boolean bool = true;; bool = false)
      {
        Preconditions.checkState(bool, "no calls to next() since the last call to remove()");
        LinkedListMultimap.a(LinkedListMultimap.this, this.c.a);
        this.c = null;
        this.d = LinkedListMultimap.a(LinkedListMultimap.this);
        return;
      }
    }
  }
  
  static final class b<K, V>
  {
    LinkedListMultimap.c<K, V> a;
    LinkedListMultimap.c<K, V> b;
    int c;
    
    b(LinkedListMultimap.c<K, V> paramc)
    {
      this.a = paramc;
      this.b = paramc;
      paramc.f = null;
      paramc.e = null;
      this.c = 1;
    }
  }
  
  static final class c<K, V>
    extends mw<K, V>
  {
    final K a;
    V b;
    c<K, V> c;
    c<K, V> d;
    c<K, V> e;
    c<K, V> f;
    
    c(@Nullable K paramK, @Nullable V paramV)
    {
      this.a = paramK;
      this.b = paramV;
    }
    
    public final K getKey()
    {
      return (K)this.a;
    }
    
    public final V getValue()
    {
      return (V)this.b;
    }
    
    public final V setValue(@Nullable V paramV)
    {
      Object localObject = this.b;
      this.b = paramV;
      return (V)localObject;
    }
  }
  
  final class d
    implements ListIterator<Map.Entry<K, V>>
  {
    int a;
    LinkedListMultimap.c<K, V> b;
    LinkedListMultimap.c<K, V> c;
    LinkedListMultimap.c<K, V> d;
    int e = LinkedListMultimap.a(LinkedListMultimap.this);
    
    d(int paramInt)
    {
      int i = LinkedListMultimap.this.size();
      Preconditions.checkPositionIndex(paramInt, i);
      if (paramInt >= i / 2)
      {
        this.d = LinkedListMultimap.b(LinkedListMultimap.this);
        this.a = i;
        while (paramInt < i)
        {
          c();
          paramInt += 1;
        }
      }
      this.b = LinkedListMultimap.c(LinkedListMultimap.this);
      while (paramInt > 0)
      {
        b();
        paramInt -= 1;
      }
      this.c = null;
    }
    
    private void a()
    {
      if (LinkedListMultimap.a(LinkedListMultimap.this) != this.e) {
        throw new ConcurrentModificationException();
      }
    }
    
    private LinkedListMultimap.c<K, V> b()
    {
      a();
      LinkedListMultimap.a(this.b);
      LinkedListMultimap.c localc = this.b;
      this.c = localc;
      this.d = localc;
      this.b = this.b.c;
      this.a += 1;
      return this.c;
    }
    
    private LinkedListMultimap.c<K, V> c()
    {
      a();
      LinkedListMultimap.a(this.d);
      LinkedListMultimap.c localc = this.d;
      this.c = localc;
      this.b = localc;
      this.d = this.d.d;
      this.a -= 1;
      return this.c;
    }
    
    public final boolean hasNext()
    {
      a();
      return this.b != null;
    }
    
    public final boolean hasPrevious()
    {
      a();
      return this.d != null;
    }
    
    public final int nextIndex()
    {
      return this.a;
    }
    
    public final int previousIndex()
    {
      return this.a - 1;
    }
    
    public final void remove()
    {
      a();
      boolean bool;
      if (this.c != null)
      {
        bool = true;
        Preconditions.checkState(bool, "no calls to next() since the last call to remove()");
        if (this.c == this.b) {
          break label84;
        }
        this.d = this.c.d;
        this.a -= 1;
      }
      for (;;)
      {
        LinkedListMultimap.a(LinkedListMultimap.this, this.c);
        this.c = null;
        this.e = LinkedListMultimap.a(LinkedListMultimap.this);
        return;
        bool = false;
        break;
        label84:
        this.b = this.c.c;
      }
    }
  }
  
  final class e
    implements ListIterator<V>
  {
    final Object a;
    int b;
    LinkedListMultimap.c<K, V> c;
    LinkedListMultimap.c<K, V> d;
    LinkedListMultimap.c<K, V> e;
    
    e(@Nullable Object paramObject)
    {
      this.a = paramObject;
      this$1 = (LinkedListMultimap.b)LinkedListMultimap.d(LinkedListMultimap.this).get(paramObject);
      if (LinkedListMultimap.this == null) {}
      for (this$1 = null;; this$1 = LinkedListMultimap.this.a)
      {
        this.c = LinkedListMultimap.this;
        return;
      }
    }
    
    public e(@Nullable Object paramObject, int paramInt)
    {
      this$1 = (LinkedListMultimap.b)LinkedListMultimap.d(LinkedListMultimap.this).get(paramObject);
      int i;
      if (LinkedListMultimap.this == null)
      {
        i = 0;
        Preconditions.checkPositionIndex(paramInt, i);
        if (paramInt < i / 2) {
          break label97;
        }
        if (LinkedListMultimap.this != null) {
          break label89;
        }
      }
      label89:
      for (this$1 = null;; this$1 = LinkedListMultimap.this.b)
      {
        this.e = LinkedListMultimap.this;
        this.b = i;
        while (paramInt < i)
        {
          previous();
          paramInt += 1;
        }
        i = LinkedListMultimap.this.c;
        break;
      }
      label97:
      if (LinkedListMultimap.this == null) {}
      for (this$1 = null;; this$1 = LinkedListMultimap.this.a)
      {
        this.c = LinkedListMultimap.this;
        while (paramInt > 0)
        {
          next();
          paramInt -= 1;
        }
      }
      this.a = paramObject;
      this.d = null;
    }
    
    public final void add(V paramV)
    {
      this.e = LinkedListMultimap.a(LinkedListMultimap.this, this.a, paramV, this.c);
      this.b += 1;
      this.d = null;
    }
    
    public final boolean hasNext()
    {
      return this.c != null;
    }
    
    public final boolean hasPrevious()
    {
      return this.e != null;
    }
    
    public final V next()
    {
      LinkedListMultimap.a(this.c);
      LinkedListMultimap.c localc = this.c;
      this.d = localc;
      this.e = localc;
      this.c = this.c.e;
      this.b += 1;
      return (V)this.d.b;
    }
    
    public final int nextIndex()
    {
      return this.b;
    }
    
    public final V previous()
    {
      LinkedListMultimap.a(this.e);
      LinkedListMultimap.c localc = this.e;
      this.d = localc;
      this.c = localc;
      this.e = this.e.f;
      this.b -= 1;
      return (V)this.d.b;
    }
    
    public final int previousIndex()
    {
      return this.b - 1;
    }
    
    public final void remove()
    {
      boolean bool;
      if (this.d != null)
      {
        bool = true;
        Preconditions.checkState(bool, "no calls to next() since the last call to remove()");
        if (this.d == this.c) {
          break label69;
        }
        this.e = this.d.f;
        this.b -= 1;
      }
      for (;;)
      {
        LinkedListMultimap.a(LinkedListMultimap.this, this.d);
        this.d = null;
        return;
        bool = false;
        break;
        label69:
        this.c = this.d.e;
      }
    }
    
    public final void set(V paramV)
    {
      if (this.d != null) {}
      for (boolean bool = true;; bool = false)
      {
        Preconditions.checkState(bool);
        this.d.b = paramV;
        return;
      }
    }
  }
}


/* Location:              /home/merong/decompile/hackery-dex2jar.jar!/com/google/common/collect/LinkedListMultimap.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */