/**
         * Adds an entry into this map, maintaining insertion order.
         * <p>
         * This implementation adds the entry to the data storage table and
         * to the end of the linked list.
         *
         * @param entry  the entry to add
         * @param hashIndex  the index into the data array to store at
         */
        protected override void addEntry(HashEntry entry, int hashIndex)
        {
            LinkEntry link = (LinkEntry)entry;

            link.after          = header;
            link.before         = header.before;
            header.before.after = link;
            header.before       = link;
            data[hashIndex]     = entry;
        }
Пример #2
0
        public static FolderResult From(FolderData item, string currentUserId)
        {
            var result = new FolderResult {
                LinkedSchema = LinkEntry.From(item.LinkedSchema, Resources.LabelLinkedSchema, currentUserId)
            };

            AddCommonProperties(item, result);
            AddPropertiesForRepositoryLocalObject(item, result, currentUserId);
            return(result);
        }
        /**
         * Removes an entry from the map and the linked list.
         * <p>
         * This implementation removes the entry from the linked list chain, then
         * calls the superclass implementation.
         *
         * @param entry  the entry to remove
         * @param hashIndex  the index into the data structure
         * @param previous  the previous entry in the chain
         */
        protected override void removeEntry(HashEntry entry, int hashIndex, HashEntry previous)
        {
            LinkEntry link = (LinkEntry)entry;

            link.before.after = link.after;
            link.after.before = link.before;
            link.after        = null;
            link.before       = null;
            base.removeEntry(entry, hashIndex, previous);
        }
        //-----------------------------------------------------------------------

        /**
         * Gets the value mapped to the key specified.
         * <p>
         * This operation changes the position of the key in the map to the
         * most recently used position (first).
         *
         * @param key  the key
         * @return the mapped value, null if no match
         */
        public override Object get(Object key)
        {
            LinkEntry entry = (LinkEntry)getEntry(key);

            if (entry == null)
            {
                return(null);
            }
            moveToMRU(entry);
            return(entry.getValue());
        }
Пример #5
0
 void handleUpdate(DijkstraUpdate update)
 {
     foreach (DijkstraLinkStateUpdate linkUpdate in update)
     {
         LinkEntry entry = links[linkUpdate.Link];
         if (entry.WhenUpdated < linkUpdate.When)
         {
             entry.IsBroken    = linkUpdate.IsBroken;
             entry.WhenUpdated = linkUpdate.When;
         }
     }
 }
Пример #6
0
 void handleState(DijkstraState state)
 {
     foreach (DijkstraLinkState linkState in state)
     {
         LinkEntry entry = links[linkState.Link];
         if (entry.WhenUpdated < state.When)
         {
             entry.IsBroken    = linkState.IsBroken;
             entry.WhenUpdated = state.When;
         }
     }
 }
        /**
         * Adds a new key-value mapping into this map.
         * <p>
         * This implementation checks the LRU size and determines whether to
         * discard an entry or not using {@link #removeLRU(AbstractLinkedMap.LinkEntry)}.
         * <p>
         * From Commons Collections 3.1 this method uses {@link #isFull()} rather
         * than accessing <code>size</code> and <code>maxSize</code> directly.
         * It also handles the scanUntilRemovable functionality.
         *
         * @param hashIndex  the index into the data array to store at
         * @param hashCode  the hash code of the key to add
         * @param key  the key to add
         * @param value  the value to add
         */
        protected internal override void addMapping(int hashIndex, int hashCode, Object key, Object value)
        {
            if (isFull())
            {
                LinkEntry reuse          = header.after;
                bool      removeLRUEntry = false;
                if (scanUntilRemovable)
                {
                    while (reuse != header && reuse != null)
                    {
                        if (removeLRU(reuse))
                        {
                            removeLRUEntry = true;
                            break;
                        }
                        reuse = reuse.after;
                    }
                    if (reuse == null)
                    {
                        throw new java.lang.IllegalStateException(
                                  "Entry.after=null, header.after" + header.after + " header.before" + header.before +
                                  " key=" + key + " value=" + value + " size=" + sizeJ + " maxSize=" + maxSizeJ +
                                  " Please check that your keys are immutable, and that you have used synchronization properly." +
                                  " If so, then please report this to [email protected] as a bug.");
                    }
                }
                else
                {
                    removeLRUEntry = removeLRU(reuse);
                }

                if (removeLRUEntry)
                {
                    if (reuse == null)
                    {
                        throw new java.lang.IllegalStateException(
                                  "reuse=null, header.after=" + header.after + " header.before" + header.before +
                                  " key=" + key + " value=" + value + " size=" + sizeJ + " maxSize=" + maxSizeJ +
                                  " Please check that your keys are immutable, and that you have used synchronization properly." +
                                  " If so, then please report this to [email protected] as a bug.");
                    }
                    reuseMapping(reuse, hashIndex, hashCode, key, value);
                }
                else
                {
                    base.addMapping(hashIndex, hashCode, key, value);
                }
            }
            else
            {
                base.addMapping(hashIndex, hashCode, key, value);
            }
        }
Пример #8
0
        public static TemplateBuildingBlockResult From(TemplateBuildingBlockData item, ISessionAwareCoreService client, string currentUserId)
        {
            var result = new TemplateBuildingBlockResult
            {
                ParametersSchema = LinkEntry.From(item.ParameterSchema, Resources.LabelParametersSchema, currentUserId),
                MetadataSchema   = LinkEntry.From(item.MetadataSchema, Resources.LabelMetadataSchema, currentUserId),
                TemplateType     = TextEntry.From(LookUpTemplateType(item.TemplateType, ItemType.TemplateBuildingBlock, client), Resources.LabelTemplateType)
            };

            AddCommonProperties(item, result);
            AddPropertiesForRepositoryLocalObject(item, result, currentUserId);
            return(result);
        }
        /**
         * Gets the index of the specified key.
         *
         * @param key  the key to find the index of
         * @return the index, or -1 if not found
         */
        public int indexOf(Object key)
        {
            key = convertKey(key);
            int i = 0;

            for (LinkEntry entry = header.after; entry != header; entry = entry.after, i++)
            {
                if (isEqualKey(key, entry.key))
                {
                    return(i);
                }
            }
            return(-1);
        }
        public static TargetGroupResult From(TargetGroupData item, string currentUserId)
        {
            int count  = item.Conditions.Count();
            var result = new TargetGroupResult
            {
                Description    = TextEntry.From(item.Description, Resources.LabelDescription),
                MetadataSchema = LinkEntry.From(item.MetadataSchema, Resources.LabelMetadataSchema, currentUserId),
                Conditions     = TextEntry.From(count > 0 ? count.ToString(CultureInfo.InvariantCulture) : Resources.None, Resources.LabelConditions)
            };

            AddCommonProperties(item, result);
            AddPropertiesForRepositoryLocalObject(item, result, currentUserId);
            return(result);
        }
 protected virtual LinkEntry nextEntry()
 {
     if (parent.modCount != expectedModCount)
     {
         throw new java.util.ConcurrentModificationException();
     }
     if (nextJ == parent.header)
     {
         throw new java.util.NoSuchElementException(AbstractHashedMap.NO_NEXT_ENTRY);
     }
     last  = nextJ;
     nextJ = nextJ.after;
     return(last);
 }
 public virtual void remove()
 {
     if (last == null)
     {
         throw new java.lang.IllegalStateException(AbstractHashedMap.REMOVE_INVALID);
     }
     if (parent.modCount != expectedModCount)
     {
         throw new java.util.ConcurrentModificationException();
     }
     parent.remove(last.getKey());
     last             = null;
     expectedModCount = parent.modCount;
 }
Пример #13
0
        public void DataBoxAddItem()
        {
            //Arrange
            var data = new DataBox("test.xml");

            //Act
            LinkEntry entry = data.NewLinkEntry("name", "description");

            //Assert
            Assert.AreEqual(1, data.Entries.Count);
            Assert.AreEqual("name", data.Entries[0].Name);
            Assert.AreEqual("description", ((LinkEntry)data.Entries[0]).Description);
            Assert.AreEqual(entry, data.Entries[0]);
        }
Пример #14
0
        // Returns the last linkpointer in a chain
        private int TraverseLinkPointerToEnd(int index)
        {
            for (int i = 0; i < links.Length; i++)
            {
                LinkEntry x = links[index];
                if (x.next == -1)
                {
                    break;
                }

                index = x.next;
            }

            return(index);
        }
Пример #15
0
 // Traverse the linkpointer and free up all seen elements.
 // Used for cleaning up after key removal
 private void TraverseLinkPointerAndFree(int index)
 {
     for (int i = 0; i < links.Length; i++)
     {
         LinkEntry x = links[(i + index) % links.Length];
         x.used   = false;
         x.next   = -1;
         x.offset = 0;
         links[(i + index) % links.Length] = x;
         if (x.next == -1)
         {
             break;
         }
     }
 }
Пример #16
0
        public void DataBoxAddItemWithLink()
        {
            //Arrange
            var data = new DataBox("test.xml");

            //Act
            LinkEntry entry = data.NewLinkEntry("name", "description");
            LinkItem  link  = entry.AddLink("link", "http://testlink.ca");

            //Assert
            Assert.AreEqual(1, data.Entries.Count);
            Assert.AreEqual("link", ((LinkEntry)data.Entries[0]).Links[0].Name);
            Assert.AreEqual("http://testlink.ca", ((LinkEntry)data.Entries[0]).Links[0].Link);
            Assert.AreEqual(link, ((LinkEntry)data.Entries[0]).Links[0]);
        }
Пример #17
0
        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            var linkEntry = new LinkEntry();

            if (!string.IsNullOrEmpty(Src))
            {
                linkEntry.Href = Src;
            }

            if (!string.IsNullOrEmpty(Rel))
            {
                linkEntry.Rel = Rel;
            }

            if (!string.IsNullOrEmpty(Condition))
            {
                linkEntry.Condition = Condition;
            }

            if (!string.IsNullOrEmpty(Title))
            {
                linkEntry.Title = Title;
            }

            if (!string.IsNullOrEmpty(Type))
            {
                linkEntry.Type = Type;
            }

            if (AppendVersion.HasValue)
            {
                linkEntry.AppendVersion = AppendVersion.Value;
            }

            foreach (var attribute in output.Attributes)
            {
                if (String.Equals(attribute.Name, "href", StringComparison.OrdinalIgnoreCase))
                {
                    continue;
                }

                linkEntry.SetAttribute(attribute.Name, attribute.Value.ToString());
            }

            _resourceManager.RegisterLink(linkEntry);

            output.TagName = null;
        }
            protected virtual LinkEntry previousEntry()
            {
                if (parent.modCount != expectedModCount)
                {
                    throw new java.util.ConcurrentModificationException();
                }
                LinkEntry previous = nextJ.before;

                if (previous == parent.header)
                {
                    throw new java.util.NoSuchElementException(AbstractHashedMap.NO_PREVIOUS_ENTRY);
                }
                nextJ = previous;
                last  = previous;
                return(last);
            }
Пример #19
0
        public void DataBoxAddMultiItems()
        {
            //Arrange
            var data = new DataBox("test.xml");

            //Act
            LinkEntry entry1 = data.NewLinkEntry("name 1", "description");
            LinkEntry entry2 = data.NewLinkEntry("name 2", "description");
            LinkEntry entry3 = data.NewLinkEntry("name 3", "description");

            //Assert
            Assert.AreEqual(3, data.Entries.Count);
            Assert.AreEqual(entry1, data.Entries[0]);
            Assert.AreEqual(entry2, data.Entries[1]);
            Assert.AreEqual(entry3, data.Entries[2]);
        }
Пример #20
0
        public void Displaying(ShapeDisplayingContext context)
        {
            if (!IsMobileDevice())
            {
                return;
            }

            var shapeMetadata = context.ShapeMetadata;

            if (shapeMetadata.Type != "HeadLinks" && shapeMetadata.Type != "Metas")
            {
                return;
            }

            var workContext     = _workContextAccessor.GetContext(_httpContextAccessor.Current());
            var resourceManager = workContext.Resolve <IResourceManager>();

            if (shapeMetadata.Type == "HeadLinks")
            {
                // <link rel="alternate" type="text/html" media="handheld" href="" />
                var handheldLink = new LinkEntry
                {
                    Type = "text/html",
                    Rel  = "alternate",
                    Href = ""
                };

                handheldLink.AddAttribute("media", "handheld");

                resourceManager.RegisterLink(handheldLink);

                // Set the transcoding protection http response headers
                workContext.HttpContext.Response.Cache.SetNoTransforms();
                workContext.HttpContext.Response.AppendHeader("Vary", "User-Agent");
            }
            else if (shapeMetadata.Type == "Metas")
            {
                resourceManager.SetMeta(new MetaEntry
                {
                    // HACK: Orchard doesn't allow metas without a name.
                    Name      = "no-transform",
                    HttpEquiv = "Cache-control",
                    Content   = "no-transform"
                });
            }
        }
Пример #21
0
        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            var linkEntry = new LinkEntry();

            if (!string.IsNullOrEmpty(Href))
            {
                linkEntry.Href = Href;
            }

            if (!string.IsNullOrEmpty(Rel))
            {
                linkEntry.Rel = Rel;
            }

            if (!string.IsNullOrEmpty(Condition))
            {
                linkEntry.Condition = Condition;
            }

            if (!string.IsNullOrEmpty(Title))
            {
                linkEntry.Title = Title;
            }

            if (!string.IsNullOrEmpty(Type))
            {
                linkEntry.Type = Type;
            }

            foreach(var attribute in output.Attributes)
            {
                if (String.Equals(attribute.Name, "href", StringComparison.OrdinalIgnoreCase))
                {
                    continue;
                }

                linkEntry.SetAttribute(attribute.Name, attribute.Value.ToString());
            }

            _resourceManager.RegisterLink(linkEntry);

            output.TagName = null;
        }
Пример #22
0
        public void RegisterLink()
        {
            var resourceManager = new ResourceManager(
                new OptionsWrapper <ResourceManagementOptions>(new ResourceManagementOptions()),
                StubFileVersionProvider.Instance
                );

            var linkEntry = new LinkEntry
            {
                Rel  = "foo",
                Href = "bar.ext"
            };

            resourceManager.RegisterLink(linkEntry);

            var registeredLinks = resourceManager.GetRegisteredLinks();

            Assert.Contains(linkEntry, registeredLinks);
        }
Пример #23
0
    protected override NetworkInterface getRoute(Node destination)
    {
        //implement dijkstra alghoritm
        clearMetrics();
        IntervalHeap <NodeEntry> sortedNodes = new IntervalHeap <NodeEntry>();
        NodeEntry us = nodes[node];

        us.Metric = 0;
        sortedNodes.Add(ref us.Handle, us);

        while (sortedNodes.Count > 0)
        {
            NodeEntry entry = sortedNodes.DeleteMin();
            if (entry.Node == destination)
            {
                return(extractInterface(entry));
            }
            foreach (NetworkInterface netInt in entry.Node.NetworkInterfaces.Interfaces.Values)
            {
                NodeEntry destinationNode = nodes[netInt.DestinationNode];
                LinkEntry destinationLink = links[netInt.Link];
                if (destinationLink.CanBeUsed)
                {
                    double totalMetric = entry.Metric + netInt.Link.Metric;
                    if (destinationNode.Metric > totalMetric)
                    {
                        destinationNode.Metric   = totalMetric;
                        destinationNode.UsedLink = netInt.Link;

                        if (destinationNode.Handle == null)
                        {
                            sortedNodes.Add(ref destinationNode.Handle, destinationNode);
                        }
                        else
                        {
                            sortedNodes.Replace(destinationNode.Handle, destinationNode);
                        }
                    }
                }
            }
        }
        return(null);
    }
Пример #24
0
        public void DataBoxAddItemWithTag()
        {
            //Arrange
            var data = new DataBox("test.xml");
            var tag  = data.NewTag("Test");

            //Act
            LinkEntry entry = data.NewLinkEntry("name", "description");

            entry.AddTag(tag);

            //Assert
            Assert.AreEqual(1, data.Entries.Count);
            Assert.AreEqual("name", data.Entries[0].Name);
            Assert.AreEqual("description", ((LinkEntry)data.Entries[0]).Description);
            Assert.AreEqual("Test", data.Entries[0].Tags.First().Name);
            Assert.AreEqual(entry, data.Entries[0]);
            Assert.IsTrue(data.Entries[0].Tags.Contains(tag));
        }
Пример #25
0
        public async Task TestInsert()
        {
            MiniLinkContext             context  = GetContext();
            IBaseRepository <LinkEntry> linkRepo = new BaseRepository <LinkEntry>(context);


            var entry  = new LinkEntry("https://www.google.com/", "", DateTime.UtcNow);
            var entry2 = new LinkEntry("https://www.facebook.com/", "", DateTime.UtcNow);

            await linkRepo.InsertAsync(entry);

            await linkRepo.InsertAsync(entry2);

            var save = await linkRepo.SaveChangesAsync();

            Assert.Equal(2, save);

            context.Dispose();
        }
Пример #26
0
        public static ComponentResult From(ComponentData item, string currentUserId)
        {
            var result = new ComponentResult {
                Schema = LinkEntry.From(item.Schema, Resources.LabelSchema, currentUserId)
            };

            if (item.ComponentType == ComponentType.Multimedia)
            {
                if (item.BinaryContent.FileSize != null)
                {
                    result.FileSize = TextEntry.From(FormatFileSize((long)item.BinaryContent.FileSize), Resources.LabelFileSize);
                }
                result.FileName = TextEntry.From(item.BinaryContent.Filename, Resources.LabelFileName);
            }

            AddCommonProperties(item, result);
            AddPropertiesForRepositoryLocalObject(item, result, currentUserId);
            return(result);
        }
Пример #27
0
        public void DataBoxAddItemWithLinkWithTag()
        {
            //Arrange
            var data = new DataBox("test.xml");
            var tag  = data.NewTag("test", "link");

            //Act
            LinkEntry entry = data.NewLinkEntry("name", "description");
            LinkItem  link  = entry.AddLink("link", "http://testlink.ca");

            link.AddTag(tag);

            //Assert
            Assert.AreEqual(1, data.Entries.Count);
            Assert.AreEqual("link", ((LinkEntry)data.Entries[0]).Links[0].Name);
            Assert.AreEqual("http://testlink.ca", ((LinkEntry)data.Entries[0]).Links[0].Link);
            Assert.IsTrue(((LinkEntry)data.Entries[0]).Links[0].Tags.Any(x => x.Name == "test"));
            Assert.AreEqual(link, ((LinkEntry)data.Entries[0]).Links[0]);
            Assert.IsTrue(((LinkEntry)data.Entries[0]).Links[0].Tags.Contains(tag));
        }
        //-----------------------------------------------------------------------

        /**
         * Moves an entry to the MRU position at the end of the list.
         * <p>
         * This implementation moves the updated entry to the end of the list.
         *
         * @param entry  the entry to update
         */
        protected virtual void moveToMRU(LinkEntry entry)
        {
            if (entry.after != header)
            {
                modCount++;
                // remove
                entry.before.after = entry.after;
                entry.after.before = entry.before;
                // add first
                entry.after         = header;
                entry.before        = header.before;
                header.before.after = entry;
                header.before       = entry;
            }
            else if (entry == header)
            {
                throw new java.lang.IllegalStateException("Can't move header to MRU" +
                                                          " (please report this to [email protected])");
            }
        }
Пример #29
0
        // calculate the spacing from node a to node b(with offset calculations).
        // Remember to add the root key offset (If array first contains something at 5 etc)
        // the indexes must exist(not sparse elements)
        private int DistancebetweenLinks(int index_a, int index_b)
        {
            int acc = 0;

            for (uint i = 0; i < links.Length; i++)
            {
                if (index_a == index_b)
                {
                    break;
                }

                LinkEntry x = links[index_a];

                acc += x.offset;

                index_a = x.next;
            }

            return(acc);
        }
Пример #30
0
        public async Task <OperationResult <LinkEntryVisit> > AddVisit(LinkEntry entry, string ip)
        {
            if (string.IsNullOrEmpty(ip))
            {
                ip = string.Empty;
            }

            var visit = new LinkEntryVisit()
            {
                LinkEntryId     = entry.Id,
                TimeStamp       = DateTime.UtcNow,
                VisitorIPAdress = ip
            };

            await _visitsRepository.InsertAsync(visit);

            await _visitsRepository.SaveChangesAsync();

            return(new OperationResult <LinkEntryVisit>(visit));
        }
Пример #31
0
 /// <summary>
 /// Loads the entries.
 /// </summary>
 public void LoadEntries()
 {
     if (Databox == null)
     {
         MessageBox.Show("File is not a Data Box file.",
                         "The selected file was not the correct format.",
                         MessageBoxButton.OK,
                         MessageBoxImage.Warning);
     }
     else
     {
         foreach (Entry entry in Databox.Entries)
         {
             LinkEntry lEntry = entry as LinkEntry;
             if (lEntry != null)
             {
                 sbMainView.Children.Add(new LinkItemControl(ref lEntry));
             }
         }
     }
 }
 /**
  * Subclass method to control removal of the least recently used entry from the map.
  * <p>
  * This method exists for subclasses to override. A subclass may wish to
  * provide cleanup of resources when an entry is removed. For example:
  * <pre>
  * protected bool removeLRU(LinkEntry entry) {
  *   releaseResources(entry.getValue());  // release resources held by entry
  *   return true;  // actually delete entry
  * }
  * </pre>
  * <p>
  * Alternatively, a subclass may choose to not remove the entry or selectively
  * keep certain LRU entries. For example:
  * <pre>
  * protected bool removeLRU(LinkEntry entry) {
  *   if (entry.getKey().toString().startsWith("System.")) {
  *     return false;  // entry not removed from LRUMap
  *   } else {
  *     return true;  // actually delete entry
  *   }
  * }
  * </pre>
  * The effect of returning false is dependent on the scanUntilRemovable flag.
  * If the flag is true, the next LRU entry will be passed to this method and so on
  * until one returns false and is removed, or every entry in the map has been passed.
  * If the scanUntilRemovable flag is false, the map will exceed the maximum size.
  * <p>
  * NOTE: Commons Collections 3.0 passed the wrong entry to this method.
  * This is fixed in version 3.1 onwards.
  *
  * @param entry  the entry to be removed
  */
 protected virtual bool removeLRU(LinkEntry entry)
 {
     return true;
 }
 //-----------------------------------------------------------------------
 /**
  * Moves an entry to the MRU position at the end of the list.
  * <p>
  * This implementation moves the updated entry to the end of the list.
  *
  * @param entry  the entry to update
  */
 protected virtual void moveToMRU(LinkEntry entry)
 {
     if (entry.after != header)
     {
         modCount++;
         // remove
         entry.before.after = entry.after;
         entry.after.before = entry.before;
         // add first
         entry.after = header;
         entry.before = header.before;
         header.before.after = entry;
         header.before = entry;
     }
     else if (entry == header)
     {
         throw new java.lang.IllegalStateException("Can't move header to MRU" +
             " (please report this to [email protected])");
     }
 }
 /**
  * Gets the <code>after</code> field from a <code>LinkEntry</code>.
  * Used in subclasses that have no visibility of the field.
  *
  * @param entry  the entry to query, must not be null
  * @return the <code>after</code> field of the entry
  * @throws NullPointerException if the entry is null
  * @since Commons Collections 3.1
  */
 protected virtual LinkEntry entryAfter(LinkEntry entry)
 {
     return entry.after;
 }
        /**
         * Reuses an entry by removing it and moving it to a new place in the map.
         * <p>
         * This method uses {@link #removeEntry}, {@link #reuseEntry} and {@link #addEntry}.
         *
         * @param entry  the entry to reuse
         * @param hashIndex  the index into the data array to store at
         * @param hashCode  the hash code of the key to add
         * @param key  the key to add
         * @param value  the value to add
         */
        protected void reuseMapping(LinkEntry entry, int hashIdx, int hashCode, Object key, Object value)
        {
            // find the entry before the entry specified in the hash table
            // remember that the parameters (except the first) refer to the new entry,
            // not the old one
            try
            {
                int removeIndex = hashIndex(entry.hashCode, data.Length);
                HashEntry[] tmp = data;  // may protect against some sync issues
                HashEntry loop = tmp[removeIndex];
                HashEntry previous = null;
                while (loop != entry && loop != null)
                {
                    previous = loop;
                    loop = loop.nextJ;
                }
                if (loop == null)
                {
                    throw new java.lang.IllegalStateException(
                        "Entry.next=null, data[removeIndex]=" + data[removeIndex] + " previous=" + previous +
                        " key=" + key + " value=" + value + " size=" + sizeJ + " maxSize=" + maxSizeJ +
                        " Please check that your keys are immutable, and that you have used synchronization properly." +
                        " If so, then please report this to [email protected] as a bug.");
                }

                // reuse the entry
                modCount++;
                removeEntry(entry, removeIndex, previous);
                reuseEntry(entry, hashIdx, hashCode, key, value);
                addEntry(entry, hashIdx);
            }
            catch (java.lang.NullPointerException )
            {
                throw new java.lang.IllegalStateException(
                        "NPE, entry=" + entry + " entryIsHeader=" + (entry == header) +
                        " key=" + key + " value=" + value + " size=" + sizeJ + " maxSize=" + maxSizeJ +
                        " Please check that your keys are immutable, and that you have used synchronization properly." +
                        " If so, then please report this to [email protected] as a bug.");
            }
        }
 //-----------------------------------------------------------------------
 /**
  * Gets the <code>before</code> field from a <code>LinkEntry</code>.
  * Used in subclasses that have no visibility of the field.
  *
  * @param entry  the entry to query, must not be null
  * @return the <code>before</code> field of the entry
  * @throws NullPointerException if the entry is null
  * @since Commons Collections 3.1
  */
 protected virtual LinkEntry entryBefore(LinkEntry entry)
 {
     return entry.before;
 }
 /**
  * Initialise this subclass during construction.
  * <p>
  * NOTE: As from v3.2 this method calls
  * {@link #createEntry(HashEntry, int, Object, Object)} to create
  * the map entry object.
  */
 protected override void init()
 {
     header = (LinkEntry)createEntry(null, -1, null, null);
     header.before = header.after = header;
 }
 protected LinkIterator(AbstractLinkedMap parent)
     : base()
 {
     this.parent = parent;
     this.nextJ = parent.header.after;
     this.expectedModCount = parent.modCount;
 }
 public virtual void remove()
 {
     if (last == null)
     {
         throw new java.lang.IllegalStateException(AbstractHashedMap.REMOVE_INVALID);
     }
     if (parent.modCount != expectedModCount)
     {
         throw new java.util.ConcurrentModificationException();
     }
     parent.remove(last.getKey());
     last = null;
     expectedModCount = parent.modCount;
 }
 public virtual void reset()
 {
     last = null;
     nextJ = parent.header.after;
 }
 protected virtual LinkEntry nextEntry()
 {
     if (parent.modCount != expectedModCount)
     {
         throw new java.util.ConcurrentModificationException();
     }
     if (nextJ == parent.header)
     {
         throw new java.util.NoSuchElementException(AbstractHashedMap.NO_NEXT_ENTRY);
     }
     last = nextJ;
     nextJ = nextJ.after;
     return last;
 }
 protected virtual LinkEntry previousEntry()
 {
     if (parent.modCount != expectedModCount)
     {
         throw new java.util.ConcurrentModificationException();
     }
     LinkEntry previous = nextJ.before;
     if (previous == parent.header)
     {
         throw new java.util.NoSuchElementException(AbstractHashedMap.NO_PREVIOUS_ENTRY);
     }
     nextJ = previous;
     last = previous;
     return last;
 }